8/17/2023 0 Comments Batch make foldor![]() ![]() Read the Microsoft article about Using command redirection operators for an explanation of 2>nul. The FOR loop does nothing on no file found in specified directory. This not important error message is suppressed by redirecting it to device NUL. In this case an error message would be output by DIR to handle STDERR (standard error). It could be that no file is found at all. The reverse order is necessary here to get the shorter file names output first respectively those with output before those with (Disk x of y). of all files in current directory matching the default wildcard pattern *.ordered reverse by name because of /O-N.in bare format which means just file name with file extension, but without file path, because of option /B.just the file names because of option /A-D (attribute not directory). ![]() The command DIR executed by started background command process outputs to handle STDOUT (standard output) of the background command process So executed is with Windows installed into C:\Windows: C:\Windows\System32\cmd.exe /c dir /A-D /B /O-N 2>nul The first FOR runs in background one more command process started with %ComSpec% /c and the command line between ' appended as additional arguments. The environment variable FolderName is defined with invalid name \ to always run in true branch of the most inner IF condition on first file. The environment variable FolderName stores the last created folder name depending on file name. The batch file directory or the specified directory is made temporarily the current directory. The batch file can be stored in the directory with the files to process or is called with path of the directory to process. If not "!DiskAddon!" = "!FileName!" for /F "delims=" %%V in ("!DiskAddon!") do set "FileName=!FileName:%%V=!"įor /F "eol=| delims=" %%K in ("!FolderName!") do (įor /F "eol=| delims=" %%V in ("!FileName!") do ( Set "DiskAddon=!FileName:*(Disk =(Disk !" Setlocal EnableExtensions DisableDelayedExpansionįor /F "eol=| delims=" %%I in ('dir /A-D /B /O-N 2^>nul') do if not "%%~fI" = "%~f0" (įor /F "eol=| tokens=1 delims=" %%J in ("%%~nI") do ( This directory creation and file moving task could be done with following batch code: offĮcho ERROR: Directory "%~1" does not exist. ![]() I would like to understand why these files did not follow the bat file pattern Zap 't' Balls - The Advanced Edition (1992)(Elmsoft Game-Service)(Disk 2 of 2) Zap 't' Balls - The Advanced Edition (1992)(Elmsoft Game-Service)(Disk 1 of 2) They were not in a single folder, disregarding the (Disk x of y) list of folders: 20000 Lieus sous les Mers (1988)(Coktel Vision)(fr)(Disk 1 of 2)Ģ0000 Lieus sous les Mers (1988)(Coktel Vision)(fr)(Disk 2 of 2)ģ Guerra Mundial (1989)(Pactum)(es)(Disk 1 of 2)ģ Guerra Mundial (1989)(Pactum)(es)(Disk 2 of 2)Ī la Conquete de l'Orthographe (1991)(Generation 5)(fr)(Disk 1 of 2)Ī la Conquete de l'Orthographe (1991)(Generation 5)(fr)(Disk 2 of 2)Ī la Pursuite de Carmen Sandiego dans le Monde (1990)(Broderbund Software)(fr)(Disk 1 of 2)Ī la Pursuite de Carmen Sandiego dans le Monde (1990)(Broderbund Software)(fr)(Disk 2 of 2) What happened some games did not behave in that way, it was the case of games 20000 Lieus sous les Mers (1988)(Coktel Vision)(fr)(Disk 1 of 2).dskĢ0000 Lieus sous les Mers (1988)(Coktel Vision)(fr)(Disk 2 of 2).dsk Mofi, thank you very much for the help and explanation of the commands, I have some problems What I would like was for the batch to put the files in the folder by names, leaving it as clean as possible: 3D Pool (1989)(Firebird Software)ģD Pool (1989)(Firebird Software)(Disk 1 of 2).dsk When using the batch it creates folders and places the files inside: 3D Pool (1989)(Firebird Software)ģD Pool (1989)(Firebird Software) My struture folder with files: 3D Pool (1989)(Firebird Software)(Disk 1 of 2).dskģD Pool (1989)(Firebird Software)(Disk 2 of 2).dskģD Pool (1989)(Firebird Software).dskĥth Axis, The (1985)(Loriciels)(fr).dsk I'm using this code to create folders and unify files with the same name, it turns out that some files worked, as was the case with 3D Pool, but other cases that files have (Disk 1 of 2), (Disk 2 of 2) did not work, could help? offįor /F "tokens=1* delims=." %%a in ('dir /B /A-D ^| sort /R') do (įor /F "delims=" %%c in ("!basename!") do if "!filename:%%c=!" equ "!filename!" (įor /F "delims=" %%c in ("!basename!") do ( ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |