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
Update modify dates on parent folders using touch
-
- Newbie
- Posts: 23
- Joined: April 6th, 2009, 3:45 am
Re: Update modify dates on parent folders using touch
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.
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
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.
I'l add support for windows 7 into it.
-
- Newbie
- Posts: 23
- Joined: April 6th, 2009, 3:45 am
Re: Update modify dates on parent folders using touch
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.
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
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.
-
- Newbie
- Posts: 23
- Joined: April 6th, 2009, 3:45 am
Re: Update modify dates on parent folders using touch
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!
Thanks for the help though!
Re: Update modify dates on parent folders using touch
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.
-
- Newbie
- Posts: 23
- Joined: April 6th, 2009, 3:45 am
Re: Update modify dates on parent folders using touch
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.
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
Does this also touch the file being downloaded? If not, how do I modify it to do that?
Thanks.
Thanks.
Re: Update modify dates on parent folders using touch
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.
UPDATE: Figured it out. Needed to run: chmod +x <file> on it.