Copy real file from a shortcut preserving the time stamps and directory tree


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy real file from a shortcut preserving the time stamps and directory tree
# 1  
Old 03-16-2013
Copy real file from a shortcut preserving the time stamps and directory tree

I have directory with shorcuts of files.
for example:
Code:
gara@yn\short\name1 ( shortcut to gara@yn\FOLDER\OPT\GARA\1.jpg )
gara@yn\short\name2 ( shortcut to gara@yn\FOLDER\OPT\GARA\11.jpg )
gara@yn\short\name3 ( shortcut to gara@yn\MARA\URSA\2.jpg )
gara@yn\short\name4 ( shortcut to gara@yn\LUUM\OOO\TRY\3.jpg )

Is they are a way i can copy the real files by having only they are shortcuts in a specific folder (gara@yn\RESULT) preserving the directory structure of the file and keeping the time stamps ?

for example
Code:
gara@yn\RESULT\FOLDER\OPT\GARA\1.jpg
gara@yn\RESULT\FOLDER\OPT\GARA\11.jpg
gara@yn\RESULT\MARA\URSA\2.jpg )
gara@yn\RESULT\LUUM\OOO\TRY\3.jpg )

with presarved time stamps.

THX Smilie

ps: LOVE YOU ALL :P

Last edited by gogok_bg; 03-18-2013 at 03:58 PM..
# 2  
Old 03-17-2013
In windows, shortcuts files are stored as .lnk files. You may write a simple VB script using TargetPath function to get the target path of .lnk files and then proceed with further processing. IMHO, instead of the "Shell Programming and Scripting" forum, you may post this question in the Windows forum.
# 3  
Old 03-17-2013
Well since i am posting here you should assume i am talking about linux not windows. I guess that C:\ made the wrong impression ^ ^.

BTW if it can`t be done assume i have a document file with the path of the files i need to copy:

Can this be copy like this:

with preserved date stamps ?

i wood really prefer if they are is a way to achieve the first task tho ( meening the one with the shorcuts )

ps: NEED to do this in LINUX if they are is still some sort of confusion Smilie
ps2: windows SUX, LINUX ROKS \o/
ps3: I am still loving u all, if you wonna know how ... i just have extremely big hart :P

Last edited by gogok_bg; 03-17-2013 at 10:07 AM..
# 4  
Old 03-17-2013
Ah, the C:\blah\blah in your initial post gave an impression that it's windows. Anyway, there's a utility in linux - 'readlink' that does the trick.

Code:
# cat file_containing_soft_links_list.dat
gara@yn/short/name1
gara@yn/short/name2
gara@yn/short/name3
gara@yn/short/name4

Code:
#! /bin/bash

while read link
do
    target=$(readlink $link)
    processed=${target#*\\} # This will chop off "gara@yn/" from the beginning of target path
    processed=${processed%\\*} # This will chop off the file name from target path.
    cp --preserve=timestamps $target gara@yn/$processed # Copy with preserved timestamps
done < file_containing_soft_links_list.dat

# 5  
Old 03-18-2013
I have readlink since i am with linux mint soo can someone pls tell me how to do the original task Smilie ?
# 6  
Old 03-18-2013
Hope you're able to see the shell script in post #4 on your browser?
# 7  
Old 03-19-2013
Now i am having problem with listing all shortcuts :/
Code:
find . -type f | sed "s#^.#$(pwd)#"

work only for files not shortcuts

And btw part of the task is preserving the directory. Not sure if you sow that, because ( not sure ) don`t see where the directory has been copy

Last edited by gogok_bg; 03-20-2013 at 05:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Directory Tree from one Server to Another

Hi, I have a serverA with Directory "/opt/app/myfiles" which is 8.5GB with more than 40000 files and 45 folders in it. I wish to transfer the folder "/opt/app/myfiles" tree structure with all the sub-directories and skip all files to another serverB. I would appreciate a command that... (4 Replies)
Discussion started by: mohtashims
4 Replies

2. Shell Programming and Scripting

How to get the Logs between two Time Stamps?

Hi, I have been working on the error Log script, where errors are pulled from server. I need to pull the data of the error logs between two dates & time, for example : 22/12/2014 20:00:00 22/12/2014 22:00:00 Whatever error have came during this duration. Now the question is the record... (6 Replies)
Discussion started by: amitgpta90
6 Replies

3. UNIX for Dummies Questions & Answers

[SOLVED] Copy subfolder to another directory preserving parent name

Hi, I have the following folder structure: Folder6100/Data Folder6100/Data Folder6120/Data Folder6120/Data Folder6140/Data Folder6140/Data Folder6160/Data Folder6160/Data Folder6180/Data Folder6180/Data Folder6200/Data Folder6220/Data Folder6240/Data Folder6260/Data... (2 Replies)
Discussion started by: alex2005
2 Replies

4. Shell Programming and Scripting

Increment time stamps.

Hi Gents. Please can you help me to solve a problem. I have a long list of files, which I need to change the time stamp. -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000009.segd -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000010.segd -r--r--r-- 1 geo2 geovect 47096216 Feb ... (11 Replies)
Discussion started by: jiam912
11 Replies

5. UNIX for Dummies Questions & Answers

Copy directory tree with files

Iam in the process of copying a directory with thousands of directories and files into a new directory. I need to preserve permissions, owner, group, date and timestamps, everything. Iam using AIX and would need help of writing the command whether it is cp-RP or cpio. Apprecaite your... (3 Replies)
Discussion started by: baanprog
3 Replies

6. UNIX for Dummies Questions & Answers

How to copy a tree of directory

Mi question is how can you copy only de three of directory and not the files in it. Only a need the three of directorys not the files (6 Replies)
Discussion started by: enkei17
6 Replies

7. Shell Programming and Scripting

Perl - Search file between two time stamps

Hi, I am on a windows system that receives files from differnet host, I have to find the count of files that we receive between specific time. The code below is what i use to count the number of file, how do i change this to count files between specfic time opendir ( DIR, $dir ) || die... (1 Reply)
Discussion started by: amit1_x
1 Replies

8. UNIX for Dummies Questions & Answers

comparing time stamps

Hello All, I'm generating timestamps (file creation timestamps) for all the files in a directory. I need to compare all the timestamps. for example if i have 4 files and their timestamps are 20091125114556, 20091125114556,20091125114556,20091125114556 respectively. I need to differentiate... (1 Reply)
Discussion started by: RSC1985
1 Replies

9. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies

10. Shell Programming and Scripting

Read from fileList.txt, copy files from directory tree

Hi, hopefully this is a fairly simple Q&A. I have a clean file list of approximately 180 filenames with no directory or slashes in front of the filename nor any extension or dot ".". I would like to read from this list, find these files recursively down through directory trees, copy the files... (1 Reply)
Discussion started by: fxvisions
1 Replies
Login or Register to Ask a Question