Unix "rename" Terminal command available in OS X?
Hello,
I have a couple of different cameras/phones that deliver their photos as
DSC00001.jpg
DSC00002.jpg
DSC00003.jpg
etc.
I want to be able to rename these files such that "DSC" is replaced by the camera or phone that took the shot. The "rename" command in Unix (and CMD prompt in XP) do exactly what I need. I just run
rename DSC*.jpg W580i*.jpg and all of file in the folder are renamed.
When I try and run the rename command in a Terminal in OS X, I get this error
mr-mbp:Pix_Xfer MR$ rename
-bash: rename: command not found
Is there a way to enable the rename command in OS X?
I found a nice script called "Replace Text in Item Names" that does what is needed however the command seems so much easier...
THx!
/MR
If I were renaming a single file mv would be perfect, but I need to do many files at once. The practicum is that I have a set of files that have an underscore in the file name. I wrote a perl script that automatically generates LaTeX code to make a book for the pictures. However, the \includegraphics command in LaTeX does not care for underscores in filenames so I want to transliterate the underscores into something more LaTeX friendly, like dashes. With rename it's as simple as this:
rename _ - *.jpg
and all of my images that had underscores in their names are replaced with dashes. mv just isn't practical when I'm looking at hundreds (or more) of images. That's why I was so interested in the build of rename from linux -- I don't care what the source is, I just need the functionality.
Now, the rename.c file does have a shell script at the top that is a very decent substitute:
#!/bin/sh
if [ $# -le 2 ]; then
echo call: rename from to files; exit;
fi
FROM="$1"
TO="$2"
shift
shift
for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
but the compiled C program does fix some potential issues, and it would also satisfy the purist in me that loves having a native compiled rendition of rename around.
Similar Messages
-
Can't seem to sync my phone with iCal because I get a message that says:No writable calendar. I tried the suggestions I found in Help including a Terminal command to no avail.
I can only suggest you now need to somehow link your mobile to sync with the new calendar 'On my Mac'.
I have a work Blackberry whose calendar I sync with an iCal calendar 'On my Mac' using a usb lead and the Blackberry Desktop Manager for Mac. This free piece of software from Blackberry, automatically starts up as soon as I connect the usb to the iMac and it then prompts me to select which calendar 'On the iMac', which is writable, that I want my Blackberry to sync to. -
Terminal commands = UNIX commands?
would I be right if I say terminal commands equal UNIX commands? I can use the same commands to write a simple rsync scripts to backup my data every night?
As I recall rsync does not preserve the Mac resource fork. In fact, you can use it to strip resource forks, which is actually useful for sharing with Windows users or putting files on a Windows server, where the resource fork drives 'em nutty (it shows as a separate file with "._filename").
Francine
Francine
Schwieder -
Unix commands = Mac Terminal commands ?
Hi,
I am a newbie to the mac and just wondering whether the Mac & Unix terminal commands are same ?
$Yes they are. Since MacOS X 10.5 Leopard, the operating system has had the full Single Unix Specification certification, meaning it complies with all we normally call "unix". Of course, as JoeyR points out, it still shows its roots from the FreeBSD and NeXTstep worlds.
If you want to compile programs in the traditional Unix fashion, by default MacOS X does not include a gcc compiler. But you can download and install the full XCode SDE for free thru the App Store, just seach for XCode. Beware it is big and will take awhile to download.
For help in specific MacOS X Unix stuff, there is the Mac OS & System Software / Mac OS X Technologies forum. -
What are all the 'Terminal' Commands?
I use Terminal for fun with the commands and the killall argument command but i really want to know all the terminal commands so that i am not that bored. I always use the commands i know but they are getting old so please help.
PLEASE!!!!!!!!!!!!
Thanks,
Andrew.The commands are be scattered around the hd. A command is any file with the execution bit set on.
The best way to go is to go to your local library and find any book on unix or bash. There will be some difference between what you read and what is available in X. the man command should key you in on the differences.
A book on Bash would be helpful.
Here is the book that I use:
Mac OS X Tiger in a Nutshell: A Desktop Quick Reference (In a Nutshell (O'Reilly))
This is also good & was in my local library.
Practical Guide to Linux Commands, Editors, and Shell Programming, A (2nd Edition) [Paperback] the book Don't be fooled by the name, the second addition includes Mac OS X.
Advanced Bash Script. premise: Examples for everything. I have revision 6.2.
tldp.org/LDP/abs/abs-guide.pdf
BASH Programming - Introduction HOW-TO
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html#toc14
Apple administrative commands
http://manuals.info.apple.com/en_US/IntroCommandLine_v10.6.pdf
Apple Shell Scripting Primer
https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/Shel lScripting/ShellScripting.pdf
Check you local library. Any book on Bash syntax will do. There will be minor differences but they will not be great.
Sometimes you can get a good deal on used books in Amazon.
Bash Cookbook, Carol Albing, JP Vossen & Cameron Newham (O'Reilly) -
Basic Terminal Commands Not Working
I'm having trouble using basic commands in terminal that I've been able to use in the past. For example, if I type "dir," I get "-bash: dir: No such file or directory"
I'm know sure what "bash" is, or if that has anything to do with it.
I'm also trying to use the tar command, which I've not used before. Again, I get a similar error: "-bash: tar: No such file or directory"
Hope you can help. Thanks!Here is an overview of the terminal commands. Lets assume that your account has a short user name of mac.
Macintosh-HD -> Applications -> Utilities -> Terminal
#What is my short user name? Type the whoami command.
mac $ whoami
mac
mac $
#How to list all of your disks.
# The ls command is for list
mac $ ls /Volumes/
Audio CD Macintosh-HD Spotless Tiger-ext
mac $
# Let's say your flash drive is named Spotless
# cd is change directory
mac $ cd /Volumes/Spotless
# pwd is print working directory
mac $ pwd
/Volumes/Spotless
mac $
# The ls command is for list # l is long # F is type of file where / is directory mac $ ls -lF
total 134704
-rw-r--r-- 1 mac staff 64560 Mar 3 2009 A-picture-of-Youpi-key.png
drwxr-xr-x 83 mac staff 2822 Nov 7 14:52 Applescript files/
drwxrwxrwx 12 mac staff 408 Dec 13 2008 Christmas Cards/
drwxr-xr-x 9 mac staff 306 Dec 21 17:39 Christmas Cards 2009/
... trimmed ... What does all this mean?
drwxrwxrwx
d = directory
r = read
w = write
x = executeable program
drwxrwxrwx
|| | |
|| | all other users not in first two types
|| |
|| group
||
|owner
|
What type of entery is this? d = directory, - = file, etc.
Every Unix resource: files, folders, etc has an owner, group, other
A Unix resource has one owner.
A Unix resource has one group. A group contains a list of users.
To gain access to a file. You can be the owner, in the group, or not being the owner or in the group you ended up as other. The owner, group, or other has read, write, or execute permissions.
# l is long
# a is all to show hidden files & folders
mac $ ls -lFa
total 134736
drwxr-xr-x 41 mac staff 1496 Dec 22 17:11 .
drwxrwxrwt 8 root admin 272 Dec 24 13:55 ..
-rwxrwxrwx 1 mac staff 15364 Dec 23 12:52 .DS_Store*
drwx------ 4 mac staff 136 Jan 22 2009 .Spotlight-V100
drwxrwxrwt 5 mac staff 170 Sep 14 16:36 .TemporaryItems
d-wx-wx-wx 4 mac staff 136 Dec 31 1969 .Trashes
-rw-r--r-- 1 mac staff 64560 Mar 3 2009 A-picture-of-Youpi-key.png
drwxr-xr-x 83 mac staff 2822 Nov 7 14:52 Applescript files
drwxrwxrwx 12 mac staff 408 Dec 13 2008 Christmas Cards
drwxr-xr-x 9 mac staff 306 Dec 21 17:39 Christmas Cards 2009
... trimmed ...
# mv is move or rename
mv -i the-name the-new-name
# You can just rename the file back to what it was with mv command.
mv -i old-name new-name
Here is what these commands mean:
cd is change directory
pwd is a print working directory
ls is list
sudo is Super user do
mv is move or rename
For cryptic comments, you can always uses the manual command which is man. For example:
man mv
# Type the letter q to quit.
In case you have spaces in your filenames or directories, you need to escape them. See examples:
mac $ ls -l ~/"see it"
-rw-r--r-- 1 mac staff 3171 Oct 26 23:38 /Users/mac/see it
mac $
mac $ cd /Users/mac/Desktop/ttt\ html\ copy/
Do you know about tabing? Type in a few letters of a name then press the tab key. The computer will type out the rest of the name if it is unique.
Press the up arrow key to see the previous command(s).
To edit a command, use the left arror key to more left and the right arror key to move right. Use the delete key to delete the key to the left. Type a letter to insert.
history to see many previous commands.
mac $ history
2 man launchd.conf
3 history
http://discussions.apple.com/thread.jspa?threadID=2692161&tstart=0
Robert -
Can anyone suggest me a handbook of mac terminal commands
Guyz I am new user of mac and I like to use the terminal. Can anyone kindly suggest me any handbook or codebook for learning basic mac terminal commands?
Spend some time in a book store that has a section of Unix/Linux oriented computer books. Find a book that discusses the Bash Shell (Bourne Again Shell; in tribute to Bourne, who wrote one of the first shell's to be popular on Unix). Bash is the default shell for Mac OS X. Such a book will give you the basics of using the shell. Most of the commands they will teach you about will work on Mac OS X, although you may run into a few commands that have slightly different options, the basics are still going to be the same.
Or a book on shell programming.
Anyway, browse the books and if you find one that "Speaks to You", then buy it.
There are also some "Mac OS X for Unix Geeks" books available that might give some Mac OS X specific Unix usage, but they also may assume a lot of existing command line knowledge.
The key think to keep in mind, is that 85% to 90% of the Mac OS X command line interface is just like every other Unix/Linux command line interface. Of course that last 10 - 15% can trip you up, and relates to specific commands and command options that may vary between Unix/Linux implementations. That being said, a lot of knowledge about another Unix/Linux platform is transferable to the Mac OS X command line. -
After transferring documents from one MacBook Pro to another I get some weird errors due to settings that seem to have transferred over. One is that the Mac App Store is disabled.
Are there any Unix / Terminal commands I can use to reset these?Forgot Your Account Password
For Lion/Mountain Lion
Boot to the Recovery HD:
Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
When the menubar appears select Terminal from the Utilities menu.
Enter resetpassword at the prompt and press RETURN. Follow
instructions in the dialog window that will appear.
Or see Reset a Mac OS X 10.7 Lion Password and
OS X Lion- Apple ID can be used to reset your user account password. -
I didn't find configure terminal command in the ios of aironet 1131AG
Dear All
i bought cisco aironet 1131AG yesterday. when the AP get IP from DHCP and trying to access it by internet browser, the web page is empty so i tried to access AP by console and login in to the privileged mode but i did't find the configure terminal command to enter the config mode.
what is the problem !!!???
is the IOS version problem?
the details of show version command :
Cisco IOS Software, C1130 Software (C1130-RCVK9W8-M), Version 12.3(11)JX1, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Mon 17-Jul-06 11:38 by alnguyen
ROM: Bootstrap program is C1130 boot loader
BOOTLDR: C1130 Boot Loader (C1130-BOOT-M) Version 12.3(8)JEA, RELEASE SOFTWARE (fc2)
AP001e.7abd.dca6 uptime is 3 hours, 9 minutes
System returned to ROM by power-on
System image file is "flash:/c1130-rcvk9w8-mx/c1130-rcvk9w8-mx"
cisco AIR-LAP1131AG-A-K9 (PowerPCElvis) processor (revision A0) with 24566K/8192K bytes of memory.
Processor board ID FOC12072A3U
PowerPCElvis CPU at 262Mhz, revision number 0x0950
Last reset from power-on
LWAPP image version 3.0.51.0
1 FastEthernet interface
32K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: 00:1E:7A:BD:DC:A6
Part Number : 73-8962-12
PCA Assembly Number : 800-24818-11
PCA Revision Number : B0
PCB Serial Number : FOC12072A3U
Top Assembly Part Number : 800-29144-02
Top Assembly Serial Number : FOC12072A3U
Top Revision Number : A0
Product/Model Number : AIR-LAP1131AG-A-K9
Configuration register is 0xFHi,
The APs image is LWAPP and to access the config t command we need to convert the IOS to Autonomous.. here is the step by step procedure that we need to follow to get the issue resolved..
C1130 Software (C1130-RCVK9W8-M)
I request you to do download any image from the below link and perform the conversion from LWAPP image to autonomous..
http://www.cisco.com/cisco/software/release.html?mdfid=279537722&flowid=6775&softwareid=280805680&release=12.4.25d-JA&rellifecycle=ED&relind=AVAILABLE&reltype=latest
the method to convert is..
download TFTPd32 from google and install it on ur PC.. point the image that you have downloaded in the TFTP server..
connect a ethernet cable between ur laptop and AP.. both should be in the same subnet.. and connect a console cable and get the hyperterminal console access and issue the command..
AP>en
AP#debug lwapp console cli or debug capwap console cli
AP#config t
AP(confg)int fa 0
AP(confg-if)ip addr (same subnet as that of the laptop)
AP(confg-if)end
AP#archieve download-sw /force-reload /overwrite tftp:///
eg-
Assuming tftp ip address is 10.0.0.1 and the image is c1130-k9w7-tar.124-25d.JA.tar, then..
AP#archieve download-sw /force-reload /overwrite tftp://10.0.0.1/c1130-k9w7-tar.124-25d.JA.tar
The AP will reload and it will come up with IOS image and you will be able to enter the config mode
lemme know if this answered your question..
Regards
Surendra
====
Please dont forget to rate the posts which answered your question and mark it as answered or was helpfull -
Terminal command to restart Samba?
Anyone know what the terminal command is to restart Samba under OS X 10.5.4?
I've searched all over and can't seem to find the answer to this question. I've tried...
/etc/rc.d/init.d/smb restart
Not valid under OS X
sudo killall -HUP smbd
Not sure if this is working as I get no indication from the terminal that anything has actually happened.
Thank YouPost your query to the Unix forum under OS X Technologies where the Unix and Terminal gurus congregate.
-
Help, i made a terminal command and i don't know how to undo it.
i found my long lost folder of terminal commands.. and i forgot what this one did, so i clicked it (i made the commands into a "unix executable file").. and all my files on my desktop are now hidden.. the only way to find them is to type in the file name into finder.
the command i typed in was
while (true) do
chflags hidden ~/Desktop/*
done
and now everything on my desktop is gone, and i dont know how to undo it, I undid once about 3 months ago when i wrote it, but i forgot what i did. I tried counterering the command with others but it isn't doing anything. thank you
edit: i know this command cant destroy my system because it wasn't a sudo, but still, i had all my class work on my laptop and now it's all invisibleHi, try this...
while (true) do
chflags nohidden ~/Desktop/*
done -
Terminal command equivalent to Automator's 'set metadata pdf'
Hi,
When I make pdf docs I sometimes want to erase my name from the Author metadata, and put something into Title and so on.
I know that Automator has an action called set pdf metadata, which I have successfully used. But I would like a Terminal command that I could use instead.
Googling this question returns suggestions of downloading pdf-manipulation libraries which are too elaborate for me to use. I'm hoping that Automator is simply utilising a terminal command already built-in.
Is there such a command?
DiddlesA bit of experimenting.
Given a file temp.pdf in the current working directory . . .
xattr -w "com.apple.metadata:kMDItemAuthors" "diddles1234" temp.pdf
writes the string "diddles1234" to the Authors metadata field of temp.pdf.
xattr -w "com.apple.metadata:kMDItemTitle" "newmetatitle" temp.pdf
writes the string "newmetatitle" to Title metadata field of temp.pdf.
However, if you try to put spaces into the string like this:
xattr -w "com.apple.metadata:kMDItemTitle" "new meta title" temp.pdf
the title field will not be changed to "new meta title". In fact, if you start with "original title" as the value of kMDItemTitle, successfully change it to "newmetatitle", and then later try to change it again to "new meta title", the value of kMDItemTitle reverts to "original title". The OS appears to "forget" the intermediate change to "newmetatitle".
As best I can figure, in the event of a failed xattr write command, the original kMDItemTitle is rebuilt from semi-redundant data within the PDF--but more experimentation would be required to prove it. (The same is true of kMDItemAuthors, by the way.) Quick take away: The first two commands above will work if you don't use spaces in the strings to be inserted into the metadata fields. Someone more proficient in UNIX may have a better solution or explanation. -
Terminal commands to Delete Desktop Folder?
Can anyone help me with the Terminal commands to delete the desktop folder? I'm not much with Unix. It's related to my previous post about missing drive space/deleted files. I'm planning to try deleting the folder then restoring from time machine.
Thanks,the command is
*sudo rm -rf ~/Desktop*
(you'll have to enter your admin password to make it work). Could you explain why you want to do this? If you have a TM backup and a serious problem with your system I would recommend doing a full system restore from TM.
Message was edited by: V.K.
Found your other post. (I even replied to it). You should definitely do a full system restore from TM. It will reformat your drive and cure the problem with the missing space. -
Terminal command that will let me access old username files...
... including files saved by timemachine? I've had a lot of computer problems, first wiped the drive. It was a chore getting old folders like "desktop" and "downloads" to open for me with my new username and for some reason I wasn't permitted by the system to use the OLD username. I had to go to every folder and every item in every folder and reset permissions.
Now, it seems, I need a new drive. Which means I have to do all those things AGAIN! Plus re-install software.
Is there a terminal command that will let me access old timemachine drives (plural) with (unfortunately) multiple usernames?
Please don't lecture me! I know I've been hopelessly stupid and inefficient. I promise to do better. At least I DID back up.what you type is
man sudo
I presented an example, which when executed will run as "username" and display the contents of their home directory - the meaning of "ls ~username"
I suspect that this is going over your head.
double-click Applications -> Utilities -> Terminal
type and hit enter
/bin/csh
This command starts the C-Shell command line interpreter. The ~ (tilde) character is translated by the C-Shell as the users home directory. For example, "ls ~" will display the contents of my home directory (folder) which is /Users/disguise
You man want to read up on C-Shell and UNIX commands. -
I recently followed these instructions to stop iTunes from automatically downloading tv shows every time I opened it:
With iTunes open select iTunes > Preferences... and click the Store tab
If checked, uncheck checkbox Always check for available downloads
If checked, uncheck checkbox Download pre-orders when available
Click the OK button, and close iTunes
Open Applications > Utilities > Terminal.app
Type cd ~/Music/iTunes/iTunes\ Media/Downloads then press <Enter>
Type rm -rf * to delete the plist file along with all of the downloads of TV shows
Re-open iTunes. There shouldn't be TV shows automatically downloading any longer when you open iTunes. Breath. Relax. Rejoice.
The result was, on restarting the computer, that all my documents, iPhoto library, iTunes library, and Mail folders were gone. I realize now that I'm not expert enough be running Terminal commands. My question is: is there any way to undo this damage?If you don't have a backup of them, try using a data recovery product such as the ones listed here. Don't write anything else to the drive until the files are recovered or you choose not to recover them.
(113837)
Maybe you are looking for
-
This problem only started recently. Opening another web page (URL) from my homepage always opens in the same tab and the "go back one page" button is gray and does not work. If I open a series of web pages in the same tab the green "back" button is g
-
I just purchased Acrobat XI pro for Mac. I have OS 10.9.2 When I got to digitally sign, it only allows me to sign using certificate- which does not render a legible name- and is an apple authorization certificate. Or if I go to "type text" the only
-
Hello Friends, I am trying to give information message in User exit while creating PO Is it possible to give message type ' I ' ??? If not how to give info message on to ME21N ?? Thanks, Ajay
-
LiveUpdate3 Doesn't See Drive, XP does
I'm having trouble finding out exactly which model CDRW was bundled with my system and unfortunately the labels don't help and LiveUpdate 3 does not recognize my drive. Windows XP says it is a ATAPI CD-RW52XMAX but the drive stickers on back say it's
-
Unusably slow initialization, keyword filtering
I primarily use iphoto as my video source, as I shoot a lot of video with my panasonic point and shoot camera (it does hd video, and very good vga). imovie 11, literally takes 5 minutes to start. I have a macbook pro, 2.8ghz, previous model, with the