Web2py user
Web2py user

Reputation: 73

How can I determine which specific string has been used in DOS?

I would like to rename files and create directories corresponding to the name of files. However, I'm in trouble with this name of files. I've exported the file names with *.mp3 to text file, and I want to rename all the name of files using

for /f "delims=" %%i in (test.txt) do rename %%i sameNameAs%%iWithoutMP3

If the file name that I want to change is "Beyonce - Halo.mp3", is there any way to use regex? It will be similar to this, if the file name has .mp3 remove it and remain rest of them in English.

Also, is there any way to separate the string with "-" ? I mean, if the string is "Beyonce - Halo.mp3", I want to create separated String "Beyonce", so that I can create a folder with it.

Please let me know if my description is not enough. I'll fix it. Thanks guys

Upvotes: 0

Views: 51

Answers (1)

Kamil
Kamil

Reputation: 13941

If you are familiar with regex - maybe use VBS script instead of CMD.

Writing and debugging something like you need will be very inefficient in CMD.

Another option is use some tools from gnuwin32 (coreutils, regex packages).

Upvotes: 1

Related Questions