Turning my lists into useable copy commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Turning my lists into useable copy commands
# 1  
Old 03-10-2015
Turning my lists into useable copy commands

Hello everyone! I currently work in the motion picture industry and we constantly receive lists of missing media from our sound department. I use a series of commands in TextWrangler in order to remake the lists into useable copy commands to automate the whole process but if I could make this work with one grep command or in some other fashion that would be amazing. Forgive me because my coding skills go about as far as googling what I need and testing things till they work.

Here is an example of a list we get from the sound department:

Code:
WA6016_03.A01.D114D54EF9A91.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6030_04A01.D11A054F4C480.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6029_03A01.D11A054F4C47D.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6031_02A01.D11A054F4C481.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6032_06A01.D11A054F4C486.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6032_04A01.D11A054F4C485.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6028_02A01.D11A054F4C47B.wav    CX_Media_06:OMFI MediaFiles:zCassie:
FRK6027_03A01.D11A054F4C47A.wav    CX_Media_06:OMFI MediaFiles:zCassie:
VI6006_01.A01.D114D54EF9A85.wav    CX_Media_06:OMFI MediaFiles:zCassie:
R6v0307,Audio Mixdo54FC00E1.wav    CX_Jeff_Render_01:OMFI MediaFiles:zJeff_AP:
Bass_Drop_A01.D10BF54E6B931.wav    CX_Media_06:OMFI MediaFiles:zTommy_AP:
Bass_Drop_A02.D10BF54E6B931.wav    CX_Media_06:OMFI MediaFiles:zTommy_AP:
R6v0225_BTA01.D118C54F38E42.wav    CX_Media_06:OMFI MediaFiles:zCassie:
R6v0225_BTA02.D118C54F38E42.wav    CX_Media_06:OMFI MediaFiles:zCassie:


And here is how I need it to look:

Code:
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/WA6016_03.A01.D114D54EF9A91.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6030_04A01.D11A054F4C480.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6029_03A01.D11A054F4C47D.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6031_02A01.D11A054F4C481.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6032_06A01.D11A054F4C486.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6032_04A01.D11A054F4C485.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6028_02A01.D11A054F4C47B.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6027_03A01.D11A054F4C47A.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/VI6006_01.A01.D114D54EF9A85.wav' copied
pause
cp '/Volumes/CX_Jeff_Render_01/OMFI MediaFiles/zJeff_AP/R6v0307,Audio Mixdo54FC00E1.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zTommy_AP/Bass_Drop_A01.D10BF54E6B931.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zTommy_AP/Bass_Drop_A02.D10BF54E6B931.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/R6v0225_BTA01.D118C54F38E42.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/R6v0225_BTA02.D118C54F38E42.wav' copied
pause

Thanks for your help!

Last edited by Scrutinizer; 03-10-2015 at 04:00 PM.. Reason: code tags
# 2  
Old 03-10-2015
Try:
Code:
awk -F'\t+|  +|:' '{$NF=$1 q " copied"; $1="pause\ncp " q "/Volumes"}1' q=\' OFS=/ file

# 3  
Old 03-10-2015
Thanks for the response!

This is almost perfect except it's doing two things that break it...

Code:
/OMFI MediaFiles/

is becoming

Code:
/OMFI/MediaFiles/

Also

Code:
R6v0307,Audio Mixdo54FC00E1.wav    CX_Jeff_Render_01:OMFI MediaFiles:zJeff_AP:

is becoming

Code:
cp '/Volumes/Mixdo54FC00E1.wav/AP_Jeff_Render_01/OMFI/MediaFiles/zJeff_AP/R6v0307,Audio' copied

when it needs to be:

Code:
cp '/Volumes/CX_Jeff_Render_01/OMFI MediaFiles/zJeff_AP/R6v0307,Audio Mixdo54FC00E1.wav' copied


All of these lists can be sourced from many different drive names and paths so the script would have to account for that. That thing was so close!

Last edited by Scrutinizer; 03-10-2015 at 04:25 PM.. Reason: code tags
# 4  
Old 03-10-2015
Strange, I get:

Code:
$ awk -F'\t+|  +|:' '{$NF=$1 q " copied"; $1="pause\ncp " q "/Volumes"}1' q=\' OFS=/ file
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/WA6016_03.A01.D114D54EF9A91.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6030_04A01.D11A054F4C480.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6029_03A01.D11A054F4C47D.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6031_02A01.D11A054F4C481.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6032_06A01.D11A054F4C486.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6032_04A01.D11A054F4C485.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6028_02A01.D11A054F4C47B.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/FRK6027_03A01.D11A054F4C47A.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/VI6006_01.A01.D114D54EF9A85.wav' copied
pause
cp '/Volumes/CX_Jeff_Render_01/OMFI MediaFiles/zJeff_AP/R6v0307,Audio Mixdo54FC00E1.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zTommy_AP/Bass_Drop_A01.D10BF54E6B931.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zTommy_AP/Bass_Drop_A02.D10BF54E6B931.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/R6v0225_BTA01.D118C54F38E42.wav' copied
pause
cp '/Volumes/CX_Media_06/OMFI MediaFiles/zCassie/R6v0225_BTA02.D118C54F38E42.wav' copied


Code:
$ echo 'R6v0307,Audio Mixdo54FC00E1.wav    CX_Jeff_Render_01:OMFI MediaFiles:zJeff_AP:' |
awk -F'\t+|  +|:' '{$NF=$1 q " copied"; $1="pause\ncp " q "/Volumes"}1' q=\' OFS=/
pause
cp '/Volumes/CX_Jeff_Render_01/OMFI MediaFiles/zJeff_AP/R6v0307,Audio Mixdo54FC00E1.wav' copied

Is your actual file different from your sample?
# 5  
Old 03-10-2015
Maybe it would help if I posted a larger example? Also I'm running this in Terminal on OS X... not sure if that makes a difference.

I've attached a real example to this post.

Thanks so much for your help.
# 6  
Old 03-10-2015
Okay I ran that example I attached in a different way and it seemed to correct the mistakes I mentioned before.

There are 11 lines that still break though by adding a // before the drive name:

Code:
cp '/Volumes//AP_SFX_01/OMFI MediaFiles/zFreeze.21/SFX - ElevA01.C4E3B74A2.1.wav' copied
cp '/Volumes//AP_Media_06/OMFI MediaFiles/zCassie/Copy of waA01.D54B0A1FA.1.wav' copied
cp '/Volumes//AP_SFX_01/Avid MediaFiles/MXF/zFreeze.3/MACHINES?RA01.C4BE04D4D.1.mxf' copied
cp '/Volumes//AP_SFX_01/OMFI MediaFiles/zFreeze.3/FX Exotic A01.C4C33B2F7.1.wav' copied
cp '/Volumes//AP_SFX_01/Avid MediaFiles/MXF/zFreeze.3/MACHINES?RA02.C4BE04D4D.1.mxf' copied
cp '/Volumes//AP_SFX_01/OMFI MediaFiles/zFreeze.3/FX Exotic A02.C4C33B2F7.1.wav' copied
cp '/Volumes//AP_Media_06/OMFI MediaFiles/zCassie/Copy of waA01.D54B0A1FA.2.wav' copied
cp '/Volumes//AP_Media_06/OMFI MediaFiles/zCassie/Copy of waA01.D54B0A1FA.3.wav' copied
cp '/Volumes//AP_Media_03/OMFI MediaFiles/consolidated/07 In the Jungl538C50A0.1.wav' copied
cp '/Volumes//AP_Jeff_Render_01/OMFI MediaFiles/zJeff_AP.1/08 Corona Radia54CA78B2.1.wav' copied
cp '/Volumes//AP_Jeff_Render_01/OMFI MediaFiles/zJeff_AP.1/R3v0205.Copy.0154D3C121.1.wav' copied

Are you seeing that on your end?

---------- Post updated at 02:44 PM ---------- Previous update was at 02:36 PM ----------

You know what? These are just files that don't exist on the drives anymore. I think your script is actually flawless.

THANK YOU SO MUCH!

Last edited by Scrutinizer; 03-10-2015 at 04:52 PM.. Reason: code tags
# 7  
Old 03-10-2015
You are welcome. This seems to work a little better with your provided input file:
Code:
awk -F'\t|:' '{sub(/ *$/,x,$1); $NF=$1 q " copied"; $1="pause\ncp " q "/Volumes"}1' q=\' OFS=/ file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Lv not useable after lvextend - high I/O

Hello, on an Ubuntu 12.04 NAS there are some lvm's VG #PV #LV #SN Attr VSize VFree vg01 1 2 0 wz--n- 930,45g 411,83g LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv-iscsi vg01 -wi-a- 500,00g lv-root vg01... (0 Replies)
Discussion started by: darktux
0 Replies

2. SCO

Need help turning off bootpd

OSR 5.0.7 patched with MP 5 The syslog is flooded with messages: May 9 13:42:12 asiwc bootpd: IP address not found: 192.168.230.215 May 9 13:42:13 asiwc bootpd: IP address not found: 192.168.230.142 May 9 13:42:50 asiwc bootpd: IP address not found: 192.168.230.202 The system... (4 Replies)
Discussion started by: migurus
4 Replies

3. Shell Programming and Scripting

Combine two lists From Multiple Grep commands.

I'm working with a file with an xml structure. I'd like to parse it down to just the bits i want. Here is and example of the file <message id="96352877" method="status"> <date rfc="Sat, 12 Mar 2011 16:13:15 -0600" unix="1299967995" /> <services> <service id="facebook"... (4 Replies)
Discussion started by: Erulisseuiin
4 Replies

4. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

5. UNIX for Advanced & Expert Users

Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop.

Hi, Just wanted to know, how can I ftp/transfer/copy a (design.tar.gz) archive from a Unix Server (sdmc222.sdmc.cp-srv.com) which is at a remote location, to my Windows Desktop. Obviously, it is not possible at cmd prompt on my Windows using the following commands :- ftp... (3 Replies)
Discussion started by: marconi
3 Replies

6. Solaris

Turning in.ftpd on and off

For two straight days someone was running in.ftpd in my server (apparently looking to break in) and when I would do "top" almost every line would read "in.ftpd". I had a unix sysadmin friend of mine shut it down and then start it back up in a day and a half and all seems OK for now. Here's what I... (1 Reply)
Discussion started by: thomi39
1 Replies

7. UNIX for Dummies Questions & Answers

Copy/Paste text as commands in AIX

Hello, I'm absolutely new to this world... but I've a problem with a terminal connected via PuTTY (or Termlite) to an AIX 5.1 application. The problem: I need to paste from clipboard a text containing both input text strings and special keys as ESC, Arrows and so on, to execute in the AIX... (1 Reply)
Discussion started by: Daniele11
1 Replies

8. UNIX for Dummies Questions & Answers

Turning Echo off

Hi, Is there any way like in dos to turn the echo off in a script? i have some lines popping up that i dont wish to be viewed when i am unziping a file it brings up the message updating: log.txt (deflated 72%) and extracting: log.txt i dont want these be viewed. Andy (4 Replies)
Discussion started by: chapmana
4 Replies

9. UNIX for Dummies Questions & Answers

Convert Jpeg to useable Unix Pics

I'm running a Sunblade 1500 with 2 XVR-100 video cards. I have Xinerama runing as well. Desktop is CDE. Can someone help me in converting Jpeg pictures so that I can use them as backdrops? Is there a way to make the picture come on both monitors instead of streaching it across both? Thanks. (1 Reply)
Discussion started by: HSTheDuck
1 Replies

10. UNIX for Advanced & Expert Users

Turning off the CDE

I am running Solaris 9 and wanted the CDE stopped when my users login. Can this be done by adding something to the .profile? Basically when they login they should be at the command line and have to start the CDE themselves. Thanks (11 Replies)
Discussion started by: meyersp
11 Replies
Login or Register to Ask a Question