Just copy our RandomNames.bat script into a folder and run it. There are comments in the batch script which explain how to use this. Update: An undo function has been added to the script. ::Note that exclamation marks must not occur within the given string. With a simple batch script you can randomly rename every file in a directory instantly. ::This function splits off the last `_`-separated item of a string. :GET_LAST_ITEM rtn_last rtn_without_last val_string Rem // Enable delayed expansion to be able to read the variables: Rem // Call sub-routine that removes the last `_`-separated part: Rem // Store current file name and extension: Setlocal EnableExtensions DisableDelayedExpansionįor /F "delims= eol=|" %%F in ('dir /B /A:-D "%_SOURCE%\%_MASK%"') do ( Replace the brackets with the correct names, such as cd c:tester. Launch the PowerToys application and activate the PowerRename option on the General. Type cd drive letter: folder 1 folder2 or whatever number of folders the path requires. To use it, download and install Microsoft’s PowerToys. The latest free tool is PowerRename, a bulk renaming tool that will let you rename many files at once right from File Explorer. Note that this fails in case any of the files contains exclamation marks ! in their names. Microsoft is on a roll with Windows 10’s open-source PowerToys. The name of the last file will become highlighted. Here is a modified script that I posted in another answer, relying on a nice hack to remove the last portion of a string separated by a certain character – the underscore _ in this case. To rename multiple files from File Explorer, select all the files you wish to rename, then press the F2 key. The last string assigned to %%b will be _laststring.ext, so the value assigned to newname will fit the processing requirement, so rename the file. Use a simple for to assign newname to the original filename with the _string removed (replaced by nothing) and add back the extension using %%~xa. Turn on the switch for Enable PowerRename if its off. WIth each name found, using delayed expansion, assign the name to filename and then replace each _ with Space_ 1.Open the PowerToys Settings window by double-clicking its System Tray icon. Perform a directory scan of all filenames matching the mask. Stamp.cmd - Batch file to rename a file to include the current date and time. After you've verified that the commands are correct, change ECHO(REN to REN to actually rename the files. MOVE - Move a file from one folder to another. The required REN commands are merely ECHOed for testing purposes. You would need to change the setting of sourcedir to suit your circumstances. FOR %%b IN (!partsname!) DO SET "newname=!filename:%%b=!%%~xa"
0 Comments
Leave a Reply. |