Windows CMD question

Associate
Joined
29 Feb 2008
Posts
1,173
Location
Nottingham
Hi,

I'm trying to rename all file extensions in a folder of sub-folders from m4a to m4b. The "REN" command doesn't seem to work when files are in sub-folders so I was wondering if there is a quicker way than doing it individually for each sub-folder.

Thanks

... and a happy new year to you all :)
 
Code:
FOR /F %%A IN ('dir c:\search\starts\here /b /s /ad /on') DO (
   CD /D %%A
   REN *.m4a *.m4b
)

obviously change you path
all this does is change into each directory and rename the files within

if typing at command line use inly one % instead of %%
 
Thanks for the reply but I can't get it to work. It says the system cannot find the file specified. Any ideas why? I copied and pasted what you put exactly (but with only 1 %) and just changed the directory to the root folder of what I'm wanting to change.
 
Last edited:
Thanks for the reply but I can't get it to work. It says the system cannot find the file specified. Any ideas why? I copied and pasted what you put exactly (but with only 1 %) and just changed the directory to the root folder of what I'm wanting to change.

paste what you done here

I suspect your path has spaces in which case you must have "c:\path with spaces\" etc etc i.e in quotes


you entered each line individually (i.e. enter at end of each line? )
 
paste what you done here

I suspect your path has spaces in which case you must have "c:\path with spaces\" etc etc i.e in quotes


you entered each line individually (i.e. enter at end of each line? )

Ah ok will try that. Suspected as much.


FOR /F %A IN ('dir C:\Users\Ivan\Desktop\Mitchell And Webb\ /b /s /ad /on') DO (
CD /D %A
REN *.m4a *.m4b
)
 
Last edited:
try :

Code:
FOR /F %A IN ('dir "C:\Users\Ivan\Desktop\Mitchell And Webb" /b /s /ad /on') DO (
   CD /D %A
   REN *.m4a *.m4b
)

or:

Code:
CD /D "C:\Users\Ivan\Desktop\Mitchell And Webb"
FOR /F %A IN ('dir . /b /s /ad /on') DO (
  CD /D %A
  REN *.m4a *.m4b
)


You know you can paste this lot into a text file and call it myfile.bat and it will run by double clicking on it. (change one % to %% to use it in a batch file though)
 
No joy i'm afraid. I tried both and here is what it does:

Untitled.jpg
 
sorry man i am sucking hard


CD /D "%A"

and the for line should read for /f "tokens=*" %a in (..... etcc

Code:
FOR /F "tokens=*" %A IN ('dir "C:\Users\Ivan\Desktop\Mitchell And Webb" /b /s /ad /on') DO (
   CD /D "%A"
   REN *.m4a *.m4b
)
 
Back
Top Bottom