Page 1 of 1
Update modify dates on parent folders using touch
Posted: February 7th, 2010, 10:26 pm
by atmurray
This script simply touches all folders in a path up to a specified parent folder.
Allows you to sort your TV folder by date so you know that a TV show has a new episode.
#!/bin/sh
# set TOPPATH to the top folder to "touch" to
# $1 is the path of the new download
TOPPATH="/data/downloads/complete/"
CURPATH=$1
while [ `expr "$CURPATH" : "$TOPPATH"` -gt 0 ]
do
# echo "Touching $CURPATH"
touch "$CURPATH"
CURPATH=`dirname "$CURPATH"`
done
Re: Update modify dates on parent folders using touch
Posted: February 23rd, 2010, 12:29 pm
by Sinnocence
Does anyone have a similar script for Windows (7)?
No matter what I try I can't seem to update the 'modified' date field, be it via unixutils, cygwin, powershell, etc.
Re: Update modify dates on parent folders using touch
Posted: February 24th, 2010, 10:23 am
by Shady
Thanks man, i'l be adding this into a soon to be released postprocessing program in java: "postman"
I'l add support for windows 7 into it.
Re: Update modify dates on parent folders using touch
Posted: February 24th, 2010, 1:35 pm
by Sinnocence
Cheers Shady.
In the end I had to write a clunky script to create a temp file and remove it from each folder in the tree to force a timestamp update - I couldn't simply 'touch' the remote shares to bump their timestamps.
Re: Update modify dates on parent folders using touch
Posted: February 25th, 2010, 3:35 pm
by Shady
I gather from your reply that you mount your ntfs shares? if you do so under linux you could take a look at fstab. setting correct parameters may update timestamps automatically.
Re: Update modify dates on parent folders using touch
Posted: February 26th, 2010, 11:30 am
by Sinnocence
Yes Shady - unfortunately the NAS I'm using (and soon replacing!) offers only minimal control over permissions. I can't even get a terminal window
Thanks for the help though!
Re: Update modify dates on parent folders using touch
Posted: February 26th, 2010, 2:02 pm
by konti
Hi sorry, but i don't understand the script. Whenever you download a episode it gets a newer timestamp right? So you'r episode are allways sorted? Could someone take the time to explain pls? thx.
Re: Update modify dates on parent folders using touch
Posted: February 27th, 2010, 6:17 am
by Sinnocence
Hi Konti,
Supposing all your downloads are stored in /mnt/Files/Downloads, each with a subcategory, e.g. /mnt/Files/Downloads/TV Shows/. If you download the Pilot for a tv show called 'MyTvShow' this would look like /mnt/Files/Downloads/TV Shows/MyTvShow/MyTvShow - 1x01 - Pilot episode.avi
Normally when this file is created, the timestamp on the 'MyTvShow' folder would be updated to the current timestamp. This isn't necessarily true for 'TV Shows' or 'Downloads' which may keep their original timestamps. The OP's script allows you to specify that it should update ALL timestamps on ALL folders between the file, and the specified 'root' directory. Now, if you're browsing Downloads and sort by date, you would see that a new TV Show episode had been downloaded.
Re: Update modify dates on parent folders using touch
Posted: April 20th, 2011, 4:13 am
by smiley5
Does this also touch the file being downloaded? If not, how do I modify it to do that?
Thanks.
Re: Update modify dates on parent folders using touch
Posted: November 10th, 2012, 5:52 pm
by simzdk
I wanted to try this script, but when i save it in my script folder, with extention .sh it dont show up. I have tried a test.py and that show up. Wrong extension?
UPDATE: Figured it out. Needed to run: chmod +x <file> on it.