Please I need so much this bat.



Moderator: DosItHelp
Code: Select all
setlocal enabledelayedexpansion
:: Make sure this ends with \
set "target=C:\...\Target Folder\"
for %%x in ("%target%*.pdf") do (
set "name=%%~nx"
if "!name:~0,6!"=="009900" set "out009900=!out009900!%%~nxx, "
if "!name:~0,6!"=="012345" set "out012345=!out012345!%%~nxx, "
echo:%%x
)
set "out009900=%out009900:~0,-2%"
set "out012345=%out012345:~0,-2%"
echo:!out009900!>"%target%009900.csv"
echo:!out012345!>"%target%012345.csv"
Code: Select all
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder="c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
If objFS.GetExtensionName(strFile) = "pdf" Then
strFileName = strFile.Name
m = InStr(strFileName,"(")
If m > 0 Then
number= Mid(strFileName,1,m-1)
strNewFileName = number&".csv"
If Not objFS.FileExists(strNewFileName) Then
Set objNewFile = objFS.CreateTextFile(strNewFileName,True)
Else
Set objNewFile = objFS.OpenTextFile(strNewFileName,8)
End If
objNewFile.Write(strFileName &",")
objNewFile.Close
End If
End If
Next
Code: Select all
c:\test> cscript //nologo myscript.vb
orange_batch wrote:So many repeat question types lately, hmm...
Puts all 009900*.pdf filenames CSV'ed into 009900.csv.
Puts all 012345*.pdf filenames CSV'ed into 012345.csv.
Code: Select all
....
m = InStr(strFileName,"(")
If m > 0 Then
....
else
' if there is no "(" in the file name
' do your stuff here.
end if