Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,359 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,223 people online right now. Registration is fast and FREE... Join Now!




Renaming a batch of files

 
Reply to this topicStart new topic

Renaming a batch of files, To rename muliple files to 8 characters

rwaldron
post 21 Aug, 2008 - 08:10 AM
Post #1


New D.I.C Head

*
Joined: 31 Mar, 2008
Posts: 10

Hi all,
I am looking to write some code that will read files in a specific folder and rename them in order to be below 8 charcaters...

say I have a folder c:\files\ and within it I have some inp files
Sample files are SIG0063501.INP , SIG0066251.INP
I want to rename these to S0063501.INP , S0066251.INP.

Essentially dropping the IG of all files read so that they are then 8 characters long.
Can someone please help me.

Thx,
Ray..
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 21 Aug, 2008 - 08:52 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,170



Thanked 33 times

Dream Kudos: 25
My Contributions


What platform? Meaning Windows vs. Mac vs Linux etc...
User is offlineProfile CardPM

Go to the top of the page

rwaldron
post 22 Aug, 2008 - 01:16 AM
Post #3


New D.I.C Head

*
Joined: 31 Mar, 2008
Posts: 10

Hiya,
Using windows..
Looking for something in say c#

I have a Bat file that seems to do the trick.
This will Take the SI off from the start of the file

:: renamer.bat
@echo off

:main
for %%f in (SIG*.inp) do call :renamer %%f
goto :eof

:renamer
set old=%1
ren %1 %old:~2,12%
:: end
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 04:33AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month