Computing.Net > Forums > Programming > copy & rename files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copy & rename files

Reply to Message Icon

Name: apsley191
Date: October 13, 2009 at 22:16:54 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Hi Everyone,
I'm looking for some help with a copy/rename problem. I have a series of files (.shp,.shx,.dbf) that sit in a series of uniquely named folders
eg FPP_maps/LJS_Highlands/FPP_newroads.(shp).(shx).(dbf)
FPP_maps/LJS_East/FPP_newroads.(shp).(shx).(dbf)
FPP_maps/HJN_Porters/FPP_newroads.(shp).(shx).(dbf)

What I'd like to do is copy all the files to one location. My problem is that all the files are named the same and I can't rename them in their current location. I what I need the batch file ito do is copy and then rename the files in a sequential order. If it was the other way around ie rename then copy I could do that.

Anyone got any ideas - any help would be greatly appreciated

Thanks
Helena



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 14, 2009 at 01:01:46 Pacific
Reply:

That's pretty cluttered up. Might help to post a TREE, like this:

C:\TEMP
└───-
├───d10
│ └───gtest
├───proxy
├───pm
├───ftp
└───prime
├───list
├───x
└───RPN
└───RPNCalc


=====================================
Helping others achieve escape felicity

M2


0

Response Number 2
Name: Mechanix2Go
Date: October 14, 2009 at 01:05:49 Pacific
Reply:

It got a bit mangled, but you get the idea.


=====================================
Helping others achieve escape felicity

M2


0

Response Number 3
Name: apsley191
Date: October 14, 2009 at 15:23:25 Pacific
Reply:

Is this what you mean?
FPP_maps
/LJS_Highlands
/FPP_newroads.(shp).(shx).(dbf)


0

Response Number 4
Name: apsley191
Date: October 14, 2009 at 15:55:28 Pacific
Reply:

Sorry - Is this what you mean?
FPP_maps
........ /LJS_Highlands
............../FPP_newroads.shp
............../FPP_newroads.shx
............. /FPP_newroads.dbf


0

Response Number 5
Name: Mechanix2Go
Date: October 15, 2009 at 06:28:25 Pacific
Reply:

not tested
========================

@echo off & setLocal enableDELAYedexpansion

set N=0
for /f "tokens=*" %%a in ('dir/b/s/a-d *.shp *.shx *.dbf') do (
set /a N+=1
if !N! LSS 10000 set S=!N!
if !N! LSS 1000  set S=0!N!
if !N! LSS 100   set S=00!N!
if !N! LSS 10    set S=000!N!
echo copy "%%a" d:\mapstuff\"%%~Na!S!%%~Xa"
)


=====================================
Helping others achieve escape felicity

M2


0

Related Posts

See More



Response Number 6
Name: apsley191
Date: October 15, 2009 at 20:13:49 Pacific
Reply:

thanks for the reply. The batch file runs okay but nothing actually copies. I've tried it copying it to a folder that already exists and one that doesn't.

Each line states something like
copy "E:\Temp\fpp_newroads.shx" E:\projects\"fpp_newroads123.shx"

Any ideas??


0

Response Number 7
Name: Mechanix2Go
Date: October 15, 2009 at 21:15:02 Pacific
Reply:

Soory, I should have told you: as posted, it simply previews what's to be done. For saftey.

To activate it, remove the ECHO which precedes COPY.


=====================================
Helping others achieve escape felicity

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: copy & rename files

Copy, rename and Move a file www.computing.net/answers/programming/copy-rename-and-move-a-file-/17888.html

Copy and Rename files with sequential number www.computing.net/answers/programming/copy-and-rename-files-with-sequential-number/19953.html

Renaming files using a batch www.computing.net/answers/programming/renaming-files-using-a-batch/11819.html