Move all files from dir and subdir to Archive with File name as complete path_filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Move all files from dir and subdir to Archive with File name as complete path_filename
# 8  
Old 05-17-2012
Of course.... I'm trying to be instructional. Smilie
# 9  
Old 05-18-2012
hi Thanks for your help. But

Code:
find . -type f -printf "%T+ %p\n" this is not working in my unix 
find: bad option -printf
find: path-list predicate-list

this error is coming.

For finding time I tried this also
Code:
find . -type f --time

again --time is not supoorted by my unix.

Last edited by Scrutinizer; 05-18-2012 at 02:06 AM.. Reason: code tags
# 10  
Old 05-18-2012
yeah you need GNU's find. Ask your admin to install it
# 11  
Old 05-21-2012
Hi both,

thanks a lot for your help. I am very near to solve my problem but as sugessted by you i am trying to use this -
Code:
find . -type f -printf "%T+ %p\n"

but my unix says -printf is unknown i tried same with -print then it says %T %p are bad options.

Also i tried to use while loop with time and path but it is not fetching time & path into it.

I am using ksh. Please let me know if you required some more info about mu unix.

Thanks.

Last edited by Franklin52; 05-21-2012 at 04:26 AM.. Reason: Please use code tags for code and data samples
# 12  
Old 05-21-2012
In my solution, you need to use GNU's find. You can replace it, however, with a perl script:
Code:
find . -type f -print | perl -mPOSIX -ne 'chop;$t = (stat($_))[9]; 
  print POSIX::strftime("%F+%T ",localtime($t)).$_."\n"'

So it's just using the traditional find command (perl can do this, but it's uglier) to feed into perl, which for each filename (reading from stdin) gets the time's filestamp ($t) and prints it out in the same format as GNU's %T+, followed by a space and the filename and the newline.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I create a tar file for only dir and its subdir structures??

How do I create a tar file for only dir and its subdir structures?? (4 Replies)
Discussion started by: vx04
4 Replies

2. Shell Programming and Scripting

Script to move all files in a dir into a certain dir

Hello all, I'm very new to shell scripting and need quite urgently to do this thing for my student job. I have a directory called "vectors" with a bunch of files all named ".vector". also i have for each of those files a directory with the name . I now want to move each of those *.vector files... (2 Replies)
Discussion started by: sherresh
2 Replies

3. UNIX for Dummies Questions & Answers

copying the dir/subdir structure from one server to another?

Hi All, I want to copy the dir/subdir structure from SERVER-A to SERVER-B without copying all the files in each dir. Is it possible using SCP / SFTP command? For example, SERVER-A has following two dir/subdirectories and files under each subdir. ... (1 Reply)
Discussion started by: Hangman2
1 Replies

4. Shell Programming and Scripting

Need a script to move the files from one dir to other other dir

Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Discussion started by: viswanathkishor
4 Replies

5. Shell Programming and Scripting

Help - Script to move files to subdir depending on file extension.

Hi, First off I'm pretty new to scripting so please be gentle. I am looking for some help with a script that will move all files with a certain extension into a folder within their current location. Just for clarity I have all my photos organised in directories such as: ... (4 Replies)
Discussion started by: guinch
4 Replies

6. Shell Programming and Scripting

Perform action in dir if dir has .git subdir

Hi, I want to run git status for the dir which has subdir ".git" in it with dir path mentioned in output log? If a dir does not have .git subdir then skip that dir. Dir will have 100 main dirs & 500 + subdirs and so on. I appreciate all your help :b: (4 Replies)
Discussion started by: dragon.1431
4 Replies

7. Shell Programming and Scripting

replace string in multiple files, dir and subdir

Hello, I have a directory www with multiple directories. Every directory has site name with .htm, .html, .php files or sub directories with .htm, .php, .html file as example - www - sitename 1 - site 1 - sitename 2 - sitename 3 What I'm looking for is a... (7 Replies)
Discussion started by: andyjill
7 Replies

8. Shell Programming and Scripting

moving dir subdir and files

I have created a directory structure and under the directory subdirectories and files are there.I need to move the entire thing to another path.How can i write a script to do that. currently the path of files is as below : /data1/serial/mcycle/archive : under this path differnt sub dir exist ... (6 Replies)
Discussion started by: dr46014
6 Replies

9. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

10. Shell Programming and Scripting

move files and retain subdir structure

hi: I have some files like this folder1/recording1.mp3 folder1/docs/budget.doc folder2/others/misc.mp3 folder3/others/notes.doc all this folders and files are under the mp3 folder. I would like to move just the mp3s to another folder but retain the subdir structure i have. So if... (4 Replies)
Discussion started by: jason7
4 Replies
Login or Register to Ask a Question