renaming files

G

Guest

hi
is there a way i could rename same files in diferent folders

ex :

folder and file tree

c:\temp\ferrari.log
c:\temp\temp1\porche.log
c:\temp\temp2\honda.log

c:
cd temp
c:\temp>ren *.log *.txt


thks
 
P

Phil Robyn [MVP]

rmachado said:
hi
is there a way i could rename same files in diferent folders

ex :

folder and file tree

c:\temp\ferrari.log
c:\temp\temp1\porche.log
c:\temp\temp2\honda.log

c:
cd temp
c:\temp>ren *.log *.txt


thks

From the CMD prompt:

for /f "tokens=*" %a in ('dir /s /b c:\temp\*.log') do @echo ren "%a" "%~na.txt"

If this appears to do what you intend, remove the word '@echo' to actually do the
renaming.

If you use this command in a batch file, double the percent signs (e.g., '%%a',
'%%~na').
 
M

Matthias Tacke

<rmachado> schrieb :
| hi
| is there a way i could rename same files in diferent folders
|
| ex :
|
| folder and file tree
|
| c:\temp\ferrari.log
| c:\temp\temp1\porche.log
| c:\temp\temp2\honda.log
|
| c:
| cd temp
| c:\temp>ren *.log *.txt
|
|
| thks
|

From the command line :

for /f "delims=" %A in ('dir /B /S c:\temp\*.log') do ren "%A"
"%~nA.txt"

In a batch double the percent signs.

The dir creates a list of all *.log file, the for passes each file to
the ren command. %~A strips path and extensions from the file leaving
the name to which the new extension .txt is appended.

For details see the help :
for /?

HTH
 
M

Matthias Tacke

Phil Robyn said:
rmachado wrote:

Hello Phil,
my newsreader failed. I'm amused - thought your message where mine.
To see the coincidence I appended it :)
From the CMD prompt:

for /f "tokens=*" %a in ('dir /s /b c:\temp\*.log') do @echo ren "%a" "%~na.txt"

If this appears to do what you intend, remove the word '@echo' to actually do the
renaming.

If you use this command in a batch file, double the percent signs (e.g., '%%a',
'%%~na').

<rmachado> schrieb :
<snip>
|
| thks
|

From the command line :

for /f "delims=" %A in ('dir /B /S c:\temp\*.log') do ren "%A" "%~nA.txt"

In a batch double the percent signs.

The dir creates a list of all *.log file, the for passes each file to
the ren command. %~A strips path and extensions from the file leaving
the name to which the new extension .txt is appended.

For details see the help :
for /?

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top