Forum Moderators: phranque

Message Too Old, No Replies

Weird question about file name changing

can this be done?

         

PFOnline

8:48 pm on Apr 2, 2004 (gmt 0)

10+ Year Member



Is there any way to automatically change a files name to include the name of the folder?

What I mean for example is:

Say I have a folder called "beatles" and within this folder are songs by them, such as "daytripper.txt"

I would need this file to be renamed beatles-daytripper.txt

And so on, for every file within it, like beatles-eight_days_a_week.txt

Then I would also have to do this for every band, (there are many) such as doors-light_my_fire.txt

Anyone know how to do this? Is this possible?

There's about 1000 bands (folders) and 20,000 songs within these folders, so it would take forever to do it by hand!

PFOnline

11:27 pm on Apr 2, 2004 (gmt 0)

10+ Year Member



I have the files and folders on my hard drive, like this:

C:\site\band\song.txt

or also uploaded to my domain name:

www.domain.com/band/song.txt

If that makes any difference...

Anyone know?

digitalv

12:18 am on Apr 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, it can be done with a few lines of code in VBScript - or through ASP using FileSystemObject.

FileSystemObject and loop through all of the files in the directory and do whatever you want with them - copy, move, delete, whatever. You can't technically "rename" through FSO, but you CAN do a "move" and set the target name of the file you're moving to a different one.

You could set the directory name as "stringa" and the filename as "stringb" and do something like this:

FSO.MoveFile stringb, stringa & "_" & stringb

Check out this page for a tutorial of FSO:

[sqldts.com...]

PFOnline

1:14 am on Apr 3, 2004 (gmt 0)

10+ Year Member



Wow, I even took a class in Visual Basic, but don't know what that means or how to do that, lol...

But thanks though, digitalv... :)

digitalv

6:32 pm on Apr 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Want me to write something for you? Do you have console access to the place where the MP3's are? (ie; can you run an EXE file?)

jim_w

7:09 pm on Apr 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also try a file called RenameIt! I'll sticky you the url. It is 32k and is shareware.

PFOnline

9:35 pm on Apr 3, 2004 (gmt 0)

10+ Year Member



digitalv, that would be AWESOME! and I can run exe's! :)

jim: It appears the RenameIt! site and download is no longer available... :(

PFOnline

9:57 pm on Apr 3, 2004 (gmt 0)

10+ Year Member



Wait, I actually found renameit from a different site, but it doesn't appear to be able to do what I need it to do... :(

I need it to be able to take the name of what folder it's in and add it to the beginning of the file name...

Like this for example...

C:\Windows\Desktop\bands\beatles\yesterday.txt

and the end result being:

C:\Windows\Desktop\bands\beatles\beatles-yesterday.txt

See how it takes the name of the last folder it's in and add's it to the beginning of the file name?

digitalv, do you think a program can be written to do that? Or anyone know of maybe any other existing programs that can do that?

py9jmas

10:29 pm on Apr 3, 2004 (gmt 0)

10+ Year Member



In a Unix BASH shell you could do something like:

$ for i in * ; do cd $i ; for j in * ; do cp ${j} ../${i}-${j}; done ; cd .. ; done

If you're stuck on windows, cmd.exe does have a for..do construct, but I'm not sure if anything similar to this would work.

Jon.

jim_w

5:29 am on Apr 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The version I have, 1.0 I think, does allow you to rename like you want. They may have taken that option out for some reason. I would send it to you, but I don't know where the install file is. If I find it, I'll let you know.

According to some of the reviews on download.com, the newest version may have fewer options. I don't know why it would though.

PFOnline

10:26 pm on Apr 4, 2004 (gmt 0)

10+ Year Member



Thanks jim, hopefully you can find it, cause I looked all over the net for renameit v1.0 and couldn't find it...

In the meantime, anyone else have any other ideas?

victor

10:43 pm on Apr 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try REBOL. From www.rebol.com

the code would be something like:

curr-folder: %beatles/
foreach file read curr-folder
[rename join curr-folder file
replace/all join cur-folder file "/" "-"
]

(Obviously, you'd build a higher-level loop to walk around all the band folders)

jim_w

7:19 am on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PFOnline

That was no doubt the best feature of version 1.0 and they took it out till they could add some more to the SW and then have a demo w/o the best feature included so that you would have to purchase the SW in order to get the best feature. (not that I have every seen that before)

Actually this is unique, I had installed it on my old computer, but when I found the network drive it was on, I double-clicked on it with my XP machine and it loaded. Because it is very small for a Windows program, I'll bet there are no activeX controls. It does come with an old version of foundation class, (MFC42.DLL), though and msvcrt.dll both in the application's folder. I just wonder, and It’s been a long time since I’ve seen it happen, if I could just send you the 5 files, (2 of them text files, the 2 mentioned above and the applications exe file), that are all installed into the application’s folder, if it would work on your machine? Since it is shareware, it would be legal and above board.