Ask a Question related to Mac Applications & Software, Design and Development.
-
Heath Raftery #1
Re: stupid unix question
Joon <spoot@spacemoose.com.invalid> wrote:
> let's say I have 5000 files that lack both extensions and type/creator
> for whatever reason. I know that they are JPEGs. I need to either add
> an extension or the type/creator stuff. I'd rather have the extension
> for windoze compatibility and batch processing for printing and
> prepress.> what is the syntax of (I guess) the "mv" command to add a .jpg
> extension to all of them, assuming the file names are all eight digits
> e.g. "0010051" and that I have cd'd to the correct directory?Well... it does require such shell constructs as a loop, so some sort of> someone told me I'd need to write a shell script to do this, and my
> blood froze. dammit Jim, I'm a print geek, not a sysadmin.
shell script is necessary. But never fear! It is three lines and you
don't even have to write a file / execute it. Just type it straight into
the shell.
I'm assuming tcsh here, which is the default in Jaguar. If you use bash
or something else, there's going to be some differences. '%' is your
shell prompt, 'foreach ->' is a mini prompt the shell also provides.
% foreach i (*)
foreach -> mv "$i" "$i.jpg"
foreach -> end
Make sure you are in the correct directory when you run this because the *
grabs all files in the current directory.
--
*--------------------------------------------------------*
| ^Nothing is foolproof to a sufficiently talented fool^ |
| Heath Raftery, HRSoftWorks _\|/_ |
*______________________________________m_('.')_m__ _______*
Heath Raftery Guest
-
Stupid Question
For as long as I've been doing Elements, I'm embarassed to ask. I've created an oval shaped image. I want to insert it into a web page as an oval... -
Stupid question.
I've worked with cfdirectory in the past but it mainly within the scope of deleting/creating a directory or get the name of files within a specific... -
OK. I'm asking a stupid question
I created a multi-frame movie to use as my website. It has five buttons on it which I added the Get URL action to. When I publish it, and then open... -
Stupid C# question Please help!
I'm used to writing my code in VBscript but I have to do this project in C#. I've written some functions on my ASP.Net page and I'm getting an... -
Is this a stupid question?
I'm looking for the command to direct a user to a new URL. For example, in ASP, when you created a dropdown box, the item selected could open a... -
Wayne C. Morris #2
Re: stupid unix question
In article <170720032303369803%spoot@spacemoose.com.invalid >,
Joon <spoot@spacemoose.com.invalid> wrote:
Instead of messing with Unix commands and scripts, try Renamer4Mac.> let's say I have 5000 files that lack both extensions and type/creator
> for whatever reason. I know that they are JPEGs. I need to either add
> an extension or the type/creator stuff. I'd rather have the extension
> for windoze compatibility and batch processing for printing and
> prepress.
>
> what is the syntax of (I guess) the "mv" command to add a .jpg
> extension to all of them, assuming the file names are all eight digits
> e.g. "0010051" and that I have cd'd to the correct directory?
>
> someone told me I'd need to write a shell script to do this, and my
> blood froze. dammit Jim, I'm a print geek, not a sysadmin.
It's a freeware GUI app that makes it easy to rename a bunch of files --
adding an extension, or numbering them sequentially, or doing a search &
replace on the filenames, etc. It'll even show you what the new
filenames will be *before* it renames them, so you can make sure you get
what you want.
<http://www.power4mac.com/>
Wayne C. Morris Guest
-
Gnarlodious #3
Re: stupid unix question
There's an Applescript included with X called "Add Pre-Suffix.scpt" that
does the job fast and easy. I use it all the time, no need to resort to
Shell commands.
I've uploaded a copy:
[url]http://home.earthlink.net/~w6zno/Add%20Pre-Suffix.scpt.sit[/url]
-- Gnarlie
Entity Joon spoke thus:
> let's say I have 5000 files that lack both extensions and type/creator
> for whatever reason. I know that they are JPEGs. I need to either add
> an extension or the type/creator stuff. I'd rather have the extension
> for windoze compatibility and batch processing for printing and
> prepress.
>
> what is the syntax of (I guess) the "mv" command to add a .jpg
> extension to all of them, assuming the file names are all eight digits
> e.g. "0010051" and that I have cd'd to the correct directory?
>
> someone told me I'd need to write a shell script to do this, and my
> blood froze. dammit Jim, I'm a print geek, not a sysadmin.
>
> j thank &deity; drag n drop to the terminal sets the working directory
> b.
Gnarlodious Guest
-
Heath Raftery #4
Re: stupid unix question
Jeremy <jeremy@exit109.com> wrote:
> Matt McLeod <matt@boggle.org> wrote:>> Here's a one-liner with no shell loop:
>>
>> find . -exec mv {} {}.jpg \;
>>
>> As always, more than one way to do it. :)> I use a shell function in zsh, which will replace an existing extension
> if one is there:> chext () {
> local file newext
> newext=$1
> shift
> for file in $argv
> do
> mv $file $(echo $file(:r)).${newext#.}
> done
> }Will that work in most shells with 5000 files? I'd be expecting a 'argument> Call as: chext .jpg *
list too long' error. Or is that up to the command to decide?
Heath
--
*--------------------------------------------------------*
| ^Nothing is foolproof to a sufficiently talented fool^ |
| Heath Raftery, HRSoftWorks _\|/_ |
*______________________________________m_('.')_m__ _______*
Heath Raftery Guest
-
Jeremy #5
Re: stupid unix question
Heath Raftery <hraftery@myrealbox.com> wrote:
No, argument list length is up to the shell, not the command. The above is>>> chext () {
>> local file newext
>> newext=$1
>> shift
>> for file in $argv
>> do
>> mv $file $(echo $file(:r)).${newext#.}
>> done
>> }
>>
>> Call as: chext .jpg *
> Will that work in most shells with 5000 files? I'd be expecting a 'argument
> list too long' error. Or is that up to the command to decide?
written for zsh, and will probably not work in any other shell.
If there are too many files, the workaround would be to call it multiple times,
each with a subset of the files.
--
Jeremy | [email]jeremy@exit109.com[/email]
Jeremy Guest



Reply With Quote

