![]() This command can be used to rename files or directories on all Windows OS editions i.e Windows 2000, XP, Vista and Windows off & setlocal enabledelayedexpansionįor /f "tokens=1-3 delims=-" %%a in ('dir /b /a:d "*-*-*"')do >nul ( Both Ren and Rename refer to the same command. We can also use ren (the short form of rename) for rename operations. If you try to do that you will get the error – “The syntax of the command is incorrect.” That is why it does not accept full path for the target file name. This command just renames the existing file/folder and does not create a new file. Note that, with rename command, we can’t move the files to another drive or directory. We can use Rename command to rename directories too. In Renaming files from command line we saw how to rename files using Rename command. ![]() For /f - Loop through command output - Windows CMD.Dir - list files and folders - Windows CMD.Windows CMD Commands (categorized) - Windows CMD.An A-Z Index of the Windows CMD command line |.Use the following batch file (test.cmd): offįor /f "tokens=1-3 delims=-" %%a in ('dir /b /a:d') do ( Move the "-bbb-X0001" directories into the corresponding renamed directories Remove all the "-aaa-X0001" parts of the names I have spent several hours getting nowhere, so am I hoping someone can help! I also tried various ideas based on: for /d "tokens=1,2,3 delims=-" I then tried using the MOVE command: MOVE *-aaa-X0001 * I soon discovered that wildcards don't work with directory names. ![]() To rename the directories, I first tried using the REN command: REN *-aaa-X0001 * ![]() I would like this all to be done using a batch file. These would each therefore contain the original contents of the corresponding "-aaa-X0001" directory, plus the corresponding "-bbb-X0001" directory as a sub-directory. I then want to move the "-bbb-X0001" directories into the corresponding renamed directories, to end up with: ABC123 I want to remove all the "-aaa-X0001" parts of the names to end up with the following: ABC123 I have fifty directories, in pairs, with names such as: ABC123-aaa-X0001 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |