General :: Use Date With Touch To Create New File With Date Based Name?
Mar 12, 2010
I am using CRON to create a new, blank file, every minute, in a specific location on my web server. After web searching, and reading man pages, I get the impression that the following command is supposed to work:touch /home/mydomain/var/folder/attachments/`date +%H%M`.txtThis should give me a new file with a file name that is the current hour and minute.However, when executed, the CRON mailer reports:touch /home/mydomain/var/folder/attachments/`date +/bin/sh: -c: line 0: unexpected EOF while looking for matching /bin/sh: -c: line 1: syntax error: unexpected end of fileSo, it looks like shell is seeing the plus (+) sign as an EOFObviously, nothing get created.What would be the easiest, single line command to create an empty file, at a given location, with a time based file name
I just switched from a basic digital camera to a more advanced one that stores both Jpeg and Raw (.Nef - it's a Nikon) files for me.When importing files in Digikam, I rename the files so that they start with Date and Time. Example: 20110121-223748.JPG for a photo taken on Jan 21st 2011 at 22:37:48.I was a bit surprised when importing both the JPEG and the Raw version of the same photo, that the filename is different by a few seconds (no constant offset, sometimes they are the same):
20110121-223748.JPG 20110121-223750.NEF
I did some "research" by looking at the exif data of both files (using "exiftool 20110121-223748.JPG" from the command line). Here is what I got back
(amongst other data):20110121-223748.JPG File Modification Date/Time : 2011:01:21 22:37:48+01:00 Modify Date : 2011:01:21 22:37:48 Date/Time Original : 2011:01:21 22:37:48
[code]....
So it seems that Digikam is using the "File Modification Date/Time" (different in the Jpeg's and Raw's of my camera) rather than the "Create Date" (the same for both Jpeg and Raw). (The few seconds difference in "File Modification Date/Time" between the two versions of the same photo is probably due to the time that my camera needs to write away the data on the SD memory card. I guess.) Is there a way to have Digikam use the Create Date? (Or the Date/Time Original?)
I would really like to preserve a file's original modified date and pass it back to the file as the same attribute after a script has worked on it. I get a lot of JPEG files from different places on the Net which I either turn around and upload or burn to disk, and having the "original" date of either download or last mod in a graphics app would be for me, in the long run, a lot more helpful when deciding, for instance, which files to "recycle" or pass on backing up more than once.I've tried doing this on my own every now and then. Where I run into problems is that it appears "stat" and "date" use different formats for date information, and I can't seem to puzzle out how to "translate" one to the other satisfactorily for the latter command.
Just to give an example: stat foo.jpg |grep Modify gives me Modify: 2010-07-12 06:28:56.890625000 -0400
Passing that string as-is to date foo.jpg, I get the errordate: unknown option -- 0 and the usual semi-courteous suggestion to Try 'date --help' for more information.Somehow my TexInfo database got screwed up somewhere along the line and info dategives me the short article on date input formats, not the full documentation for the command
### TO DO: Determine the report file name based on the source directory name and current date### The report name and thumbnail directory must follow this pattern: source-%j-%H### for example, for pictures in /home/you/pictures, the file name will be: pictures-%j-%H### HINT: Use sed to extract the directory name from the path and combine it with date command output
How to get the week number in linux using gawk with different first day of the week? the date command can give me the week number with +%V but it is based on Monday (1-53) or +%U (based on Sunday, 0-53).
I tried to to do this: date -d "ddmmyy+2days" +%V, but the result is not correct. I want the first day of the week is based on Saturday.
I know find can do what I am looking for, but I am wondering if there is an alternative way to find files on the filesystem either created before/after a certain point, or at a certain time.
Typically I rely on updatedb & locate for most of my file searching needs. Issues with those tools, though, are that it only has directory and file names, and it only creates a database of local directories, not anything mounted via CIFS|NFS or via -o loop (eg, .iso images).
So if I need to find files created after yesterday across the entire system (local and remote filesystems), I am currently needing to use find.
What other tools, if any, would accomplish this in a similar fashion?
I have tried ls and grep, but that requires (in my attempts so far) multiple searches:
ls -lR | grep Aug | grep 10 ls -lR | grep Aug | grep 11
i am running into few problems with the script here. I have an FTP server, all configured, and i need to have a script that will create a folder with current dated within a tree as soon as particular user logs in. I was wondering if that is possible with proftpd. if not, can someone suggest how to create a script that will simply create a DIR with date and autorun itself every 24 hours? i am running Debian/Proftpd with Mysql authorization.
I'm looking for a method for modifying some jpg photo files last modification date with the corresponding timestamp creation date of each file.The reason is that shotwell import pictures in folders according to last modification date which is stupid on my opinion.
I'm trying to write a script which will take mysqldump from a server and put it in a directory with today's date. Here's the script i've written so far:
Code: #!/bin/sh BACKUP=/data/backup/sql2/new_backup/daily cd $BACKUP mkdir `date '+%m%d%y'`
[Code]....
I want to put the mysql dump in the today's directory. How can i declare this?
As a photographer I'm constantly taking photos and storing them in folders. Now occasionally I'm using two cameras (either for different settings or an assistant is also taking photos) which means that for one event I can have differently named images.Both cameras have the same time set (which always helps in Windows) but in Ubuntu when trying to sort my folder by date taken I can't.The options I'm given are to sort them: Manually, by Name, by Size, by Type, by Modification date and by Emblem.Now none of those are helpful to me once I've done a few edits to the images.So please if anyone knows, how do you organise a folder with images taken on different cameras by Date Taken rather than Date Edited?
Is there any other short/easier and smarter way to do the following in Linux? code...
I need to use crontab to create folders every day and every month inside /home/abcd/dammi, /home/abcd/harrami, /home/wxyz/dammi and /home/wxyz/harrami. Can anyone help me with this?
I have hundreds of MTS and AVI files since 2000 and would like to rename them in the following manner based on the date created: DD-MMM-YYYY HH.MM.SS_X; where X begins at 1 and increments by 1 if there are dublicate date/time stamped videos.
Ex: 19-Nov-2002 08.12.30.avi, 19-Nov-2002 08:13:30_1 and 19-Nov-2002 08:13:30_2
Someone previously wrote the following script for me, and it works great for photos. It uses EXIV2 to get the image date created info. I have tried to understand the script, but am struggling. The video files I have can use the date modified since I have not modified them since I filmed them.
#!/usr/bin/env python import os import stat import pyexiv2 import time directory = '/home/david/Desktop/test' [Code].....
Originally Posted by Kenny_StrawnPlease wrap [CODE] tags aroung any code posted here. The full source that way could still be posted.I am trying to copy all the files in the directory based on the modification date (i.e created on Dec 29). Not able to find the proper command for this. This is what I have tried.
I'm trying to put the date in the name of my file but cant seem to get it I just end up with the word date in the file instead of the date. my script looks like this.
#!/bin/bash x="/var/log/system/" y=date z=${y:11:8} top > $x$y.txt
Sequentially number files based on date modified (rename cli)
I'm almost done a larger script which takes all the pictures in a folder, converts it to video, and emails it to me. Everything worked fine until I realized the picture filenames weren't always starting at 1, then ffmpeg chokes.
I have a bunch of files in a folder which I need to rename to:
I don't want to install any additional packages and I'd like this to run in a single command if possible.
If not possible, then a bash script would work too.
I need to get the modified date on a file in linux to use in a script.I tried using 'ls -l' on the file, but this caused problems when the date turned from a single digit into a double. The reason for the problem was because I was parsing the result string on spaces.How can I get the date of the last time a file was modified so I can use it in a script? For example, if a file was modified on 1/11/2010, I need the 11.
I have some basic experiencing creating simple scripts/making directories/changing permissions/etc. but I'm stumped on this one.
I have two linux boxes. I have a script set up on box 'A' to SCP into box 'B', grab a copy of a database backup and store it on box 'A'. It looks like this:
I have generated a public key on box 'A' and placed it into the authorized_keys file on box 'B', so a password is not required and the file copies over successfully when the script is run. On to my problem...
I need to know what date the 'dump.23.gz' file was originally created when I'm viewing it after it's been copied to box 'A'. If I ls -l on box 'A' it only shows me the date it was created on box 'A' when it was copied.
What would I need to add to my script to append the backup's original creation date on box 'B' to the filename so that when it gets copied to box 'A' I know when the backup was created on box 'B'. I'm sure this is probably confusing. I've done lots of searching and can only find information on how to append the current date and time to a file name. I need to append it's original creation timestamp to the filename when it copies over.
I wrote this little script and I need some help, I am trying to achieve following:Every day I receive new file in the /home/denis/MyData/ folder and I don't know what the file mane will be but I want to move any file that arrives there to the new location /media/DataBackup/Linux/backup/ (media/DataBackup/ is external 500GB USB drive)to automatically create new folder with the date and time stamp every day and then to move content of the /home/denis/MyData/ into the new folder with current date stamp. So every day there will be new folder and will contain files for that day only.My script is as follows:
cd /media/DataBackup/Linux/backup/ mkdir MyData_$(date +%Y%b%d_%HH%MM) #this creates file MyData_current date and time
I am currently working on a script which makes regular backups of some data I have, and I would like to name the compressed TAR files with the date it they were created, in short I want to rename a file:
I'm hardly keen on using (strictly, only or just) -t, --date=, -m -t, -c -m or -a -t, for all of which I'm clued in to their respective working date syntaxes, but if I must, I will. Frankly -d still boggles. I'd like to think there IS a correct format or formats, else why would they carry it forward in a coreutil command from (whenever it was first written) to the latest updates for the several distros?
Or is it so obvious I can't see the forest for the smell of the trees?
I have two linux servers, they are backup together.
1. Server 1 have 3 files with name: file1, file2, file3 in the path: /etc/sysconfig/network-script/.
2. Server 2 have 3 files with name and path are the same as server 1.
- How to make a script to copy 3 files at server1 to overwrite on server2. But before overwrite, this script will check and compare the last modified date of these 3 files(on server1 and server2). if the modified date of file1, file2 or file3 on server1 is newer than 3 files on server2 then overwrite process will do, if not, will do nothing.
- see my script as below: it works find now but just overwrite. not check last modified date.