Computing.Net > Forums > Programming > Simple batch script. Need Help.

Simple batch script. Need Help.

Reply to Message Icon

Original Message
Name: SeekingWisdom
Date: June 26, 2008 at 14:19:54 Pacific
Subject: Simple batch script. Need Help.
OS: WindowsXPSP3
CPU/Ram: 2GB
Model/Manufacturer: Dell
Comment:

Hello.
I'm a complete newb to scripting and would like some help. What I'm trying to accomplish is just simply prefixing information to a file name.
Example:
File1 to old_File1
File2 to old_File2
etc...

I tried.

@echo off
RENAME "c:\PATH\To\Files\*.txt" "Old_*.txt"

It doesn't work.. it renamed two files, removed some characters in the. It didn't work at all how expected and it also failed how I did not expect it to either.

Please help!

Thank you!


Report Offensive Message For Removal

Response Number 1
Name: devil_himself
Date: June 26, 2008 at 19:39:24 Pacific
Subject: Simple batch script. Need Help.
Reply: (edit)

@echo off
setlocal
set src=c:\test
pushd "%src%"
for /f "tokens=*" %%a in ('dir /b /s /a-d *.txt') do (ren "%%a" "old_%%~na%%~xa")


Report Offensive Follow Up For Removal

Response Number 2
Name: SeekingWisdom
Date: June 27, 2008 at 07:04:01 Pacific
Subject: Simple batch script. Need Help.
Reply: (edit)

Thanks. I appreciate it.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Simple batch script. Need Help.

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software