crosswire
November 7, 2005, 08:39 PM
I am writing a program that is suppose to rename files on the hard drive
eg
Question1.htm --> Quest1.htm
Question1.htm --> Quest2.htm
Question1.htm --> Quest3.htm
Question1.htm --> Quest4.htm
How it does this is by 1) listing all the files in a directory in a list box, then 2) lets the user replace a common string in all the file names, then 3) actually renaming the files as they appear in the list box. So if I wanted to shorten all the file names in a folder, I could replace the common name with a shorter name. What I am looking for are features that I could add to the program. I already putting in drag and drop of files in the list box. Any ideas? And what kind of additional renaming could I put in, like re-numbering the files.
When I finish it I will post it so that people can test it and correct bugs present.
Nestersan
November 8, 2005, 07:58 AM
There is a really amazing one i use to rename .jpg files for reading in sequential order.
http://www.skyjuicesoftware.com/?qfrper
Use it for some ideas
pogi_2nr
November 8, 2005, 09:05 AM
windows programmers.. y'all need to take a page from a unix user's book. :)
C:\temp\poc0>dir
Volume in drive C has no label.
Volume Serial Number is 2811-2356
Directory of C:\temp\poc0
11/08/2005 09:40 AM <DIR> .
11/08/2005 09:40 AM <DIR> ..
10/01/2005 08:23 PM 0 19p9.tmp
09/30/2005 02:49 PM 0 1ge1E5.tmp
10/15/2005 04:42 PM 0 3gp5.tmp
10/15/2005 04:42 PM 0 3gp6.tmp
10/15/2005 04:42 PM 0 3gp7.tmp
10/01/2005 08:10 PM 0 4ll3.tmp
10/17/2005 03:50 PM 0 54013.tmp
10/06/2005 09:08 AM 0 5yt7.tmp
10/18/2005 01:12 PM 0 7h78C.tmp
10/17/2005 03:50 PM 0 am012.tmp
09/05/2005 08:55 AM 14,016 angry5.png
04/01/1996 04:48 PM 82,011 cctv01-3.pdf
10/05/2005 03:43 PM 6,684 cpu.png
09/30/2005 01:54 PM 0 e4i18F.tmp
09/30/2005 01:26 PM 0 esp17F.tmp
02/15/2005 11:14 PM 18,048 gt.sql
07/21/2005 04:40 PM 341 tvguide.sed
07/17/2003 04:00 AM 75,922 _iu14D2N.tmp
11/08/2005 09:24 AM 16,384 ~DFD972.tmp
11/02/2005 10:50 AM 212,992 ~WRF0001.tmp
11/02/2005 04:54 PM 5,208 ~WRS0000.tmp
21 File(s) 431,606 bytes
2 Dir(s) 3,149,037,568 bytes free
we have our listing..
C:\temp\poc0>dir/b | gawk "{i++;split($1,a,\".\");print sprintf(\"%s.%.4d.%s\",a[1],i,a[2])}"
19p9.0001.tmp
1ge1E5.0002.tmp
3gp5.0003.tmp
3gp6.0004.tmp
3gp7.0005.tmp
4ll3.0006.tmp
54013.0007.tmp
5yt7.0008.tmp
7h78C.0009.tmp
am012.0010.tmp
angry5.0011.png
cctv01-3.0012.pdf
cpu.0013.png
e4i18F.0014.tmp
esp17F.0015.tmp
gt.0016.sql
tvguide.0017.sed
_iu14D2N.0018.tmp
~DFD972.0019.tmp
~WRF0001.0020.tmp
~WRS0000.0021.tmp
we can manipulate the name to our liking :D, lets rename.
C:\temp\poc0>dir/b | gawk "{i++;split($1,a,\".\");print sprintf(\"ren %s %s.%.4d.%s\",$1,a[1],i,a[2])}"
ren 19p9.tmp 19p9.0001.tmp
ren 1ge1E5.tmp 1ge1E5.0002.tmp
ren 3gp5.tmp 3gp5.0003.tmp
ren 3gp6.tmp 3gp6.0004.tmp
ren 3gp7.tmp 3gp7.0005.tmp
ren 4ll3.tmp 4ll3.0006.tmp
ren 54013.tmp 54013.0007.tmp
ren 5yt7.tmp 5yt7.0008.tmp
ren 7h78C.tmp 7h78C.0009.tmp
ren am012.tmp am012.0010.tmp
ren angry5.png angry5.0011.png
ren cctv01-3.pdf cctv01-3.0012.pdf
ren cpu.png cpu.0013.png
ren e4i18F.tmp e4i18F.0014.tmp
ren esp17F.tmp esp17F.0015.tmp
ren gt.sql gt.0016.sql
ren tvguide.sed tvguide.0017.sed
ren _iu14D2N.tmp _iu14D2N.0018.tmp
ren ~DFD972.tmp ~DFD972.0019.tmp
ren ~WRF0001.tmp ~WRF0001.0020.tmp
ren ~WRS0000.tmp ~WRS0000.0021.tmp
C:\temp\poc0>dir/b | gawk "{i++;split($1,a,\".\");system sprintf(\"ren %s %s.%.4d.%s\",$1,a[1],i,a[2])}"
gawk: cmd. line:1: {i++;split($1,a,".");system sprintf("ren %s %s.%.4d.%s",$1,a[1],i,a[2])}
gawk: cmd. line:1: ^ parse error
C:\temp\poc0>dir/b | gawk "{i++;split($1,a,\".\");system(sprintf(\"ren %s %s.%.4d.%s\",$1,a[1],i,a[2]))}"
C:\temp\poc0>dir
Volume in drive C has no label.
Volume Serial Number is 2811-2356
Directory of C:\temp\poc0
11/08/2005 09:56 AM <DIR> .
11/08/2005 09:56 AM <DIR> ..
10/01/2005 08:23 PM 0 19p9.0001.tmp
09/30/2005 02:49 PM 0 1ge1E5.0002.tmp
10/15/2005 04:42 PM 0 3gp5.0003.tmp
10/15/2005 04:42 PM 0 3gp6.0004.tmp
10/15/2005 04:42 PM 0 3gp7.0005.tmp
10/01/2005 08:10 PM 0 4ll3.0006.tmp
10/17/2005 03:50 PM 0 54013.0007.tmp
10/06/2005 09:08 AM 0 5yt7.0008.tmp
10/18/2005 01:12 PM 0 7h78C.0009.tmp
10/17/2005 03:50 PM 0 am012.0010.tmp
09/05/2005 08:55 AM 14,016 angry5.0011.png
04/01/1996 04:48 PM 82,011 cctv01-3.0012.pdf
10/05/2005 03:43 PM 6,684 cpu.0013.png
09/30/2005 01:54 PM 0 e4i18F.0014.tmp
09/30/2005 01:26 PM 0 esp17F.0015.tmp
02/15/2005 11:14 PM 18,048 gt.0016.sql
07/21/2005 04:40 PM 341 tvguide.0017.sed
07/17/2003 04:00 AM 75,922 _iu14D2N.0018.tmp
11/08/2005 09:24 AM 16,384 ~DFD972.0019.tmp
11/02/2005 10:50 AM 212,992 ~WRF0001.0020.tmp
11/02/2005 04:54 PM 5,208 ~WRS0000.0021.tmp
21 File(s) 431,606 bytes
2 Dir(s) 3,147,251,712 bytes free
:eusa_danc
Ref: http://www.gnu.org/software/gawk/manual/gawk.html#String-Functions
crosswire
November 8, 2005, 04:38 PM
@pogi2ner, you solution seems interesting.
@Nestersan , I will add the undo rename, I checkinh other features.
crosswire
November 8, 2005, 09:04 PM
I will add support to select files in the list box that match a search word or simple regular expression. eg Select "*.jpg"
I will add some sort of expression to allow the files to be enumerated automatically. eg Rename ".jpg" to "[ddd].jpg"
Later I will try to add mp3 atributes naming.
I did the program already still in C#. It was pretty fun and easy, in a night ago, with the drag and drop, I snipped a lot of code. That part was not finished but I could have finished it by just assigning an array. I was doing something else that night too.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.