File Renaming/Copying

G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

I have a large number of files that need to be
renamed/copied by basically stripping off the first 2
characters. I've been unable to get a copy/rename command
to do this (e.g. copy AA*.* *.* or some such). Any ideas
as to how I can get this done? Do you possibly have a
script which might do this?
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

microsoft.public.win2000.file_system:

RichLich wrote:
> I have a large number of files that need to be renamed/copied by
> basically stripping off the first 2 characters. I've been unable to
> get a copy/rename command to do this (e.g. copy AA*.* *.* or some
> such). Any ideas as to how I can get this done?

You should learn Perl. I recommend this book:

http://www.oreilly.com/catalog/lperl3/index.html


You can either use ActiveState Perl:

http://www.activestate.com/


Or the Cygwin environment:

http://www.cygwin.com/


> Do you possibly have a script which might do this?

1. The best answer is above.

2. You could go begging on Internet boards.

3. You could hire a contract programmer.


HTH,

David
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

RichLich wrote:
> I have a large number of files that need to be
> renamed/copied by basically stripping off the first 2
> characters. I've been unable to get a copy/rename command
> to do this (e.g. copy AA*.* *.* or some such). Any ideas
> as to how I can get this done? Do you possibly have a
> script which might do this?

You can do this easily with a batch file; no need for Perl. ;-)

- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>dir c:\junkdir\*.txt
Volume in drive C has no label.
Volume Serial Number is 3056-C16B

Directory of c:\junkdir

05/06/2004 12:41p 0 aafileone.txt
05/06/2004 12:41p 0 bbfiletwo.txt
06/30/2003 03:03p 205,392 cis_batch_jun2003.txt
08/19/2003 10:48a 0 jvers.txt
01/28/2003 11:19a 0 testsize.txt
10/10/2002 10:37a 0 this is a long file name.txt
6 File(s) 205,392 bytes
0 Dir(s) 3,500,118,016 bytes free

C:\cmd>demo\Rename94578
move "c:\junkdir\aafileone.txt" "c:\junkdir\fileone.txt"
move "c:\junkdir\bbfiletwo.txt" "c:\junkdir\filetwo.txt"
move "c:\junkdir\cis_batch_jun2003.txt" "c:\junkdir\s_batch_jun2003.txt"
move "c:\junkdir\jvers.txt" "c:\junkdir\ers.txt"
move "c:\junkdir\testsize.txt" "c:\junkdir\stsize.txt"
move "c:\junkdir\this is a long file name.txt" "c:\junkdir\is is a long file name.txt"

C:\cmd>rlist demo\Rename94578.cmd
=====begin C:\cmd\demo\Rename94578.cmd ====================
1. @echo off
2. setlocal
3. for %%a in (c:\junkdir\*.txt) do call :move_it "%%a"
4. goto :EOF
5. :move_it
6. set old_name=%~n1
7. set new_name=%old_name:~2%%~x1
8. echo move %1 "%~dp1%new_name%"
9. goto :EOF
=====end C:\cmd\demo\Rename94578.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -

If this appears to do what you require, remove the word 'echo' from line 8
to actually move/rename the files.

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l