View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 8 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject: Copy Linked File?
PostPosted: Wed Jul 08, 2009 9:30 am 
Offline
Joined: Tue Apr 11, 2006 7:44 am
Posts: 287
Location: Los Angeles, CA
Hello,

I got a new NAS box and I am looking to move some of my recordings to this location. What I would really like to do is use the /myth/pretty directory to be able to easily choose the files to move. However, I don't want to move the /myth/pretty symlink, I want to move the actual linked file.

eg:

mv (or cp) --some-switch /myth/pretty/NiceNameOfShow.mpg /myth/NASdir

The result I am looking for is to have the /myth/pretty symlink still there, but have the /myth/tv/1011.....mpg file moved (or copied) to the new location.

Is this possible? Or am I going to have to manually figure out which of the hard to decipher files in /myth/tv correspond to the many shows I want to move?

Thanks,

_________________
Tim

LinHES 8.4
HDHR3
BioStar A770, AMD X2 4050e, 2GB RAM
GigaByte GeForce 8400, Chaintech AV710
USB-UIRT


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 1:03 pm 
Offline
Joined: Fri Apr 02, 2004 10:08 am
Posts: 1637
Location: Virginia, USA
Good news for you: if you copy a file from /myth/pretty it copies the original (symlinked) file WITH the pretty name.

I regularly mount /myth/pretty and copy from that to another computer to do transcoding. That's a smb-based copy but I'm sure cp would do the same.

Someone with more Linux knowledge (i.e. just about anyone) can fill in the details about why this works, but it always has for me.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 1:55 pm 
Offline
Joined: Tue Apr 11, 2006 7:44 am
Posts: 287
Location: Los Angeles, CA
Right, and I want it to copy with the un-pretty name.

_________________
Tim

LinHES 8.4
HDHR3
BioStar A770, AMD X2 4050e, 2GB RAM
GigaByte GeForce 8400, Chaintech AV710
USB-UIRT


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 2:56 pm 
Offline
Joined: Fri Apr 02, 2004 10:08 am
Posts: 1637
Location: Virginia, USA
Sorry about that. Must learn to READ posts thoroughly. :-/

Here's a thread from Ubuntu support forums that is discussing the exact solution you want. It looks like it's more involved than just a switch for cp or mv.

http://ubuntuforums.org/showthread.php?t=1104173


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 3:10 pm 
Offline
Joined: Tue Apr 11, 2006 7:44 am
Posts: 287
Location: Los Angeles, CA
Wow, thanks. I had tried Google searching on all sorts of words, but I guess never the right set. That looks like the exact situation I am working with. Now to parse through the thread a little bit to see how to actually get it done.

Thanks again!

_________________
Tim

LinHES 8.4
HDHR3
BioStar A770, AMD X2 4050e, 2GB RAM
GigaByte GeForce 8400, Chaintech AV710
USB-UIRT


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 7:53 pm 
Offline
Joined: Tue Apr 11, 2006 7:44 am
Posts: 287
Location: Los Angeles, CA
Thought I would come back and post my final results. Using the previously linked post, I created a "move2nas.sh" script that will take a command-line variable of the files you want to copy.
Code:
#!/bin/bash
#make sure the /myth/pretty location is up to date
su mythtv -c /usr/local/bin/mythlink.sh

#modify the IFS variable to work with file names with spaces
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for i in `ls /myth/pretty/$1`; do
   DESTINATION=/myth/tv3/
   RECORDING=`ls -l "$i" | grep ^l | grep "$i" | awk -F "-> " '{print $2}'`;
   echo Pretty - $i
   echo Source - "$RECORDING"
   echo Destination - $DESTINATION
   mv -v $RECORDING* "$DESTINATION"
done

#set IFS back to the default value
IFS=$SAVEIFS

So the actual usage is:
Code:
move2nas.sh CSI*

This will move all of the original files related to any TV show that starts with "CSI". to see what it would copy, you can do:
Code:
ls /myth/pretty/CSI*

This will move the actual mpg file along with any screenshot icons. Hope this is helpful to someone else. Of course you will need to modify the $DESTINATION location to suit your needs.

_________________
Tim

LinHES 8.4
HDHR3
BioStar A770, AMD X2 4050e, 2GB RAM
GigaByte GeForce 8400, Chaintech AV710
USB-UIRT


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 08, 2009 9:39 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
You can probably shorten that pipe used to set RECORDING using the readlink command:
Code:
RECORDING=$(readlink "$i")

Also note the use of the modern Posix $() form of back tick `` expansion. It's a lot easier to read, nests cleanly, and is generally immune to "quoting hell" problems. Highly recommended.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 09, 2009 7:34 pm 
Offline
Joined: Tue Apr 11, 2006 7:44 am
Posts: 287
Location: Los Angeles, CA
Thanks, that part was from what I copied, so it is always nice to learn other ways to get something accomplished. And it is definitely more readable.

_________________
Tim

LinHES 8.4
HDHR3
BioStar A770, AMD X2 4050e, 2GB RAM
GigaByte GeForce 8400, Chaintech AV710
USB-UIRT


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu