Linux / UNIX Tech Support Forum
This is a discussion on copy file with standard name by inserting file-date and time in name within the File Servers forums, part of the Mastering Servers category; Hi, I run some server-based webcams, they place non-descriptive files in a folder each x seconds. "camshot.jpg", "camshot1.jpg" and "camshot2.jpg" ...
|
|||||||
| File Servers Discussion about Samba, NFS and other UNIX / Linux file servers. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I run some server-based webcams, they place non-descriptive files in a folder each x seconds. "camshot.jpg", "camshot1.jpg" and "camshot2.jpg" (for example). These files get overwritten each time the webcams put them there. (Since this is hardcoded in the webcams, I can't change that..) Now I would like to be able to archive those files with a cron command. To achieve that I need to copy a file the webcam drops (in its dedicated folder) to a different folder, and then insert a date-time in the name, like so: /www/netcam/camshot.jpg /www/netcam/camshot1.jpg will be copied as/to (for example): /www/archive/20090615_22h50m24s_camshot.jpg /www/archive/20090615_22h52m12s_camshot1.jpg Inserted time and date should be obtained from the file-creation stamp (last modified time). Anyone have a script I can use for this? (Can be perl, bash or whatever runs on a debain-based server.) There's a Windows script I found for a similar task here, but don't know how to best use it in a linux-world.. Thanks for any and all hints, M Last edited by meowing; 06-07-2009 at 08:13 PM. |
| Sponsored Links | ||
|
|
|
|||
|
Hmm.. this doesn't work for what I want. It tars folders and ads a hostname. I only need to copy a file and have part of the name of the file changed.
Basically, all I need is: camshot.jpg copied to some other folder as 20090713_22h50m24s_camshot.jpg where that date-time string is crucial and should look exactly like this; YYYYMMDD_HHhMMmSSs_originalfilename.jpg What part of your script causes the date+time insertion? Because I see $folderToBackup return only once, and that's in the tar.gz part. Last edited by meowing; 07-07-2009 at 05:23 AM. |
|
||||
|
The portion of the script that inserts the date is:
Code:
#get date string $dateString = `date +%Y%m%d`; chop($dateString); Change that to: Code:
#get date string $dateString = `date +%Y%m%d_%Hh%Mm%Ss_`; chop($dateString); Code:
[root@server ~]# date +%Y%m%d_%Hh%Mm%Ss_camshot.jpg 20090708_08h46m28s_camshot.jpg [root@server ~]# I will try to write something that does that. I am still learning scripting. I may be over thinking this as well. Jaysunn Jaysunn |
| The Following User Says Thank You to jaysunn For This Useful Post: | ||
meowing (08-07-2009)
| ||
|
|||
|
Quote:
Thanks for the effort anyway Last edited by meowing; 08-07-2009 at 08:25 PM. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell date command for manipulation and formatting date | newbie4 | Shell scripting | 4 | 28-10-2008 07:33 PM |
| Find Unix Linux File / Directory by date And Then Copy / Move File | asim.mcp | CentOS / RHEL / Fedora | 1 | 10-08-2008 03:30 AM |
| shell script to search specific file from txt file inside zip file and extract it | aasif.shaikh | Shell scripting | 2 | 31-05-2008 06:44 PM |
| How can I redirect the output of time command to file | warren | Linux software | 13 | 25-08-2006 11:17 AM |
| How can I rename a file by its date? | warren | Linux software | 5 | 30-03-2006 12:11 PM |