|
|
ack! Help with awk!
|
|
|
|
Mac Enthusiast
Join Date: Jan 2001
Location: ny ny usa
Status:
Offline
|
|
I am trying to move all my mp3 files to one directory. Itunes 3 screwed up my organization. So I built a list of all my mp3 files with:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">find /Users/chico -name "*.mp3" > list</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I would like to build a list of commands with awk to move each file to the current directory.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">awk '{print "mv '", $0, "' ."}' list > cmd</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">unfortunatly *all* my .mp3 files have white spaces in their names. so I need to wrap the file name in '. But the ' char is reserved by awk.
|
'Satisfy the urge and discover the need' Q-Tip
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Sep 2000
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by muchfresh:
<strong>I am trying to move all my mp3 files to one directory. Itunes 3 screwed up my organization. So I built a list of all my mp3 files with:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">find /Users/chico -name "*.mp3" > list</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I would like to build a list of commands with awk to move each file to the current directory.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">awk '{print "mv '", $0, "' ."}' list > cmd</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">unfortunatly *all* my .mp3 files have white spaces in their names. so I need to wrap the file name in '. But the ' char is reserved by awk.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I'm not good with awk but have you tried to put a backslash infront of ' ?
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jan 2001
Location: ny ny usa
Status:
Offline
|
|
backslash, fowardslash and double quotes do not work.
|
'Satisfy the urge and discover the need' Q-Tip
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by muchfresh:
<strong>I am trying to move all my mp3 files to one directory. Itunes 3 screwed up my organization. So I built a list of all my mp3 files with:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">find /Users/chico -name "*.mp3" > list</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I would like to build a list of commands with awk to move each file to the current directory.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">awk '{print "mv '", $0, "' ."}' list > cmd</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">unfortunatly *all* my .mp3 files have white spaces in their names. so I need to wrap the file name in '. But the ' char is reserved by awk.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Leaving the awk syntax question aside for a moment, why are you using awk at all?
From reading the scripts, you're using find to generate a file containing all the .mp3s on your system, you're then using awk to generate another file containing a slew of mv commands.
You are aware that find can make the move for you, aren't you?
using find's -exec switch, you can execute any shell command on each match.
for example:
find /Users/chico -name "*.mp3" -exec mv {} /path/to/new/location \;
In the above example, each found match will execute the "mv {} /path/to/new/location" command (note that {} is substituted with the filename matched by the find command).
|
Gods don't kill people - people with Gods kill people.
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Oct 2000
Status:
Offline
|
|
Here's guessing at something I know little about ...
It isn't an awk problem. It's a shell problem. The tcsh and csh don't allow (all? any?) escape characters.
bash will let you escape characters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|