Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darice Terry

macrumors newbie
Original poster
Feb 12, 2008
1
0
I am in an online class and need to send a folder with 10 files to the teacher. The pc uses can use F2 and it will rename all the files with the one name of the folder. Does anyone know how to do this on the Mac Ibook?
 

satyam90

macrumors regular
Jul 30, 2007
242
0
Bangalore, India
if u are talking about windows "F2" for renaming, the same way u can accomplish the task on Mac is to right click (or ctrl+click) and select "Get Info" from the popup. In that u can rename the folder name.

2nd method:
Use "terminal" or "console" and go to that place of folder. use "mv (actual_name) (final_name)"

Has my answer solved ur problem?
 

ChrisA

macrumors G5
Jan 5, 2006
12,561
1,672
Redondo Beach, California
I am in an online class and need to send a folder with 10 files to the teacher. The pc uses can use F2 and it will rename all the files with the one name of the folder. Does anyone know how to do this on the Mac Ibook?

What exactly do you need to do. Yopu say "rename all the files with the one name of the folder" but I'm sure yo don't want want all the files to have the same name. You want each file to have a differnt name right?

It's trivral in the terminal to change file names. The command of "mv" (just two leters) if you want to apply the mv command to multiple files then you might use mv in conjucion with "find" where you tell find which files need to be mv'd.
 

ThierryL

macrumors newbie
Dec 2, 2009
8
0
TotalCommander or Terminal

The question is wrong; if you press F2 on a PC when selecting 10 files, the last filename of the selection will open, and there is no way you can automatically retrieve the name of the folder to add as a prefix or suffix to all 10 files.

You can quickly do this using terminal as suggested by a previous post, but I would add that you can do multiple entries at the same time. Using TextWrangler (free) column mode, it's easy to create a bash shell script this way. As you may know, the terminal allows easy copy-paste on a Mac.

If you're not script-oriented, you can use DiskOrder3 or TotalCommander. You can use TotalCommander on your Mac if you have VMware Fusion 3 in "unity" mode. So you run it as any Mac app.

Hope this helps
 

spice weasel

macrumors 65816
Jul 25, 2003
1,255
9
Automator should do the trick for batch changes like that.

+1. Automator is very easy to use, and will let you do batch changes to filenames. Look for the right workflow (should be something like "Rename finder items") under the "Finder" column in Automator. I'm not in front of my Mac right now, but it should be clear and easy to find.

Drag the items you want to rename into the workflow pane in Automator. Then drag the Rename workflow script under that. Enter the filename you want to use and select the options (serial naming, etc.) Start the workflow and it will be done in a heartbeat.
 

Big Dave

macrumors 6502
Nov 27, 2007
313
23
Crestview, Fl
You can also use the terminal to rename files.

This is just a quick example of one use and hopefully with google or macrumors forums you can tailor it to your use.
Let's say you have 5 files.
file1
file2
file3
file4
file5
You want to add the .txt extension to the file.
Open an editor and enter the following in a file named script:
#!/bin/bash
for i in file*
do
mv $i $i.txt #The mv command means move. Use cp to copy.
done

Then make the script executable.
$chmod +x script
Then launch it
./script
 

bwana

macrumors newbie
Sep 6, 2001
5
0
liked the script.
tried to modify it to remove the .txt extension of ALL files in a directory and make copies
these files are named 1.txt , 2.txt , etc


like so


#!/bin/bash
for i in *
do
cp $i.txt $i #The mv command means move. Use cp to copy.
done


got a LOT of errors for example

cp: 990.txt.txt: No such file or directory


help?
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
liked the script.
tried to modify it to remove the .txt extension of ALL files in a directory and make copies
these files are named 1.txt , 2.txt , etc


like so


#!/bin/bash
for i in *
do
cp $i.txt $i #The mv command means move. Use cp to copy.
done


got a LOT of errors for example

cp: 990.txt.txt: No such file or directory


help?

In this case $i with have the .txt on the end of it already. $i expands to 990.txt and so $i.txt expands to 990.txt.txt.

You need to remove the trailing .txt from $i. The ${var%suffix} syntax will expand by removing suffix from variable var.

Try using this cp command in your script.
Code:
cp $i ${i%.txt}
 

sero

macrumors member
Aug 28, 2008
91
14
The best way to batch rename, IMO, is to drop the attached perl script in your bin and use regex. E.g.
PHP:
rename s/foo/bar/ *.txt
 

Attachments

  • rename.zip
    1.6 KB · Views: 639

mikeschmeee

macrumors 6502a
Mar 9, 2009
665
0
Renaming utilities: (google them)

Name Mangler
NameChanger
Renamer4Mac
Automator (not as good as the others)

I know this is an old thread but thanks for this! I downloaded NameChanger and it worked! So fast. It renamed over just under 11,000 photos from my GoPro within a few seconds. Didn't make duplicates either just simple renamed.

Thanks again!
 

sm789

macrumors newbie
Dec 9, 2011
1
0
My problem!!!

I am new here so I don't know if I am supposed to start a new post..

My problem is as follows - My technical department generates an excel report every other day. Their system is automated so the file name is very long and goes like this Multiproduct Technical Report for 2011 12 06 by Jones.xls. I have hundreds of reports like this. Is there a way where I can change the names of all the files to say MTP 2011 xx xx.xls? Basically I want to preserve the unique date, remove "by XYZ" and modify (shorten) the "Multiproduct Technical Report" to something like "MTP"?

Thank you for your help.

sm
 

LateOne

macrumors newbie
Mar 7, 2010
12
2
S . Yorks
I just thought I'd mention the (perhaps) obvious, that simple file renaming is available by putting Applescript in the menu bar via the Applescript Editor ( Utilities) preferences.

Then, having selected your files to rename, select it in the menubar, choose Finder Scripts and there are options to Add (to) and Trim (from) file names.

Not hugely sophisticated but it's done the job for me in the past.

It nearly does the job that sm789 wants to do ( assuming multiple passes ) but I suspect there's an issue with the 'by Jones' bit because it won't always be Jones.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Is there a way where I can change the names of all the files to say MTP 2011 xx xx.xls? Basically I want to preserve the unique date, remove "by XYZ" and modify (shorten) the "Multiproduct Technical Report" to something like "MTP"?

Thank you for your help.

sm

If I understood this correctly, the only thing that needs to be preserved is the date, and make sure that the file name matches the form exactly so that no other files accidentally are renamed. In this case:

"Multiproduct Technical Report for ${date} by ${name}.xls"

Here's one approach with bash.

Code:
#!/bin/bash
#
# Check for arguments

if [ $# -ne 1 ]
then
    echo "Arguments: <file to be renamed>"
    exit 1
fi

# Make sure that the file name is of the form: ""Multiproduct Technical Report for ${date} by ${name}.xls"
test=$(echo "$1" | grep -P "^Multiproduct Technical Report for \d{4}\s\d{2}\s\d{2} by \w+\.xls$")

if [ -n "$test" ]
then
    date=$(echo "$1" | cut -d" " -f5-7)
    [COLOR="SeaGreen"]echo "MTP ${date}.xls"[/COLOR]
    [COLOR="Red"]#mv "$1" "MTP ${date}.xls"[/COLOR]
fi

This just echoes the new name to the terminal to confirm that it works as intended. To rename the file you would have to move the # symbol from the red line to the green. Use at your own risk etc.
 

MattiasN

macrumors newbie
Nov 29, 2009
26
0
Gothenburg, Sweden
Interesting thread! Do you know how to rename files in multiple folders recursively where the renaming should be an added prefix that has been taken from the folder name?

For example, to set the date as the prefix on each photo file in each date folder in the following folder structure?

2012-01-01 (Folder contains jpg photo files taken on the 1st of Jan 2012)
2012-02-28 (Folder contains jpg photo files taken on the 28th of Feb 2012)
2012-03-15 (Folder contains jpg photo files taken on the 15th of Mar 2012)
...

It would be even more fantastic if it was possible to shorten the inserted date prefix to just "YYMMDD_" instead of insert the original full date and the dashes "YYYY-MM-DD_".

The original file name is "DSCF12345.jpg"
The renamed file name should be: "120101_DSCF12345.jpg"
 
Last edited:

MacBpro

macrumors member
Mar 30, 2011
67
0
Chicago, IL
Cant believe why apple make it so complicated for some frequently use functions!!!! It sounds like we are going back to the apple 2 age... need to memorize all the commands!!!

Do they have any idea there is a big room for them to improve and make it really USER FRIENDLY!!!????:mad:

really makes me sick!!!
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Cant believe why apple make it so complicated for some frequently use functions!!!! It sounds like we are going back to the apple 2 age... need to memorize all the commands!!!

Do they have any idea there is a big room for them to improve and make it really USER FRIENDLY!!!????:mad:

really makes me sick!!!

Frequently used? Seriously? I'm in my 29th year using Macs and have never, ever found any need to do this.
 

ghellquist

macrumors regular
Aug 21, 2011
146
5
Stockholm Sweden
And if you start the terminal window, there are lots and lots of variations on how to do the renaming. Lurking in there is a full Unix system, with all of the commands either already installed or easily downloadable.

Learning to use the shell commands or perl or similar programming languages will take a bit of effort but can be very worthwhile.

There are of course graphical programs doing some of these things, but if your exact requirement is not handled you are generally off on your own. Then shell is your friend.

//Gunnar
 

OlandeseVolante

macrumors newbie
Feb 8, 2011
3
0
Turin, Italy
Hello! :)

I think I'm having the same problem of Darice Terry, but I'm guessing, since he's never replied again to his own thread.

Just today I was looking for a friendly way to rename multiple files with the same name (different extensions of course!) on Mac OS X Lion, but I haven't found any yet.

Let me explain. With Windows 7, in order to rename two files at once, for example an AVI file with a Subtitles file:

file1.avi
file2.srt

I can select them both, press F2 (or Right click > Rename), and type the new name once. The result will be:

new_name.avi
new_name.srt

With OS X, I have to click on the first file and type the new name, then click on the second file and do the same.

Is there an easier way, not involving scripting? I can't believe that Windows can be more user friendly than OS X :)

Thanks!
 
Last edited:

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Hello! :)

I think I'm having the same problem of Darice Terry, but I'm guessing, since he's never replied again to his own thread.

Just today I was looking for a friendly way to rename multiple files with the same name (different extensions of course!) on Mac OS X Lion, but I haven't found any yet.

Let me explain. With Windows 7, in order to rename two files at once, for example an AVI file with a Subtitles file:

file1.avi
file2.srt

I can select them both, press F2 (or Right click > Rename), and type the new name once. The result will be:

new_name.avi
new_name.srt

With OS X, I have to click on the first file and type the new name, then click on the second file and do the same.

Is there an easier way, not involving scripting? I can't believe that Windows can be more user friendly than OS X :)

Thanks!

You're in the programming section.
Terminal, man mv
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.