Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 3, 2013, 11:31 AM   #1
MoodyM
macrumors 6502
 
Join Date: Aug 2008
App to change attributes of file

I need an app to change the attributes of a whole batch of files, specifically the date created/modified. I have A Better Finder Attributes, but it doesn't have the 1 feature I really need, namely the ability to add some time (a few seconds would do or a day or whatever) to the date created/modified for the next file in the batch.

For example if I have:

file1.avi
file2.avi
file3.avi

I want to be able to modify the Date Created for file1.avi to, say, 01 Jan 13, then automatically add, say, 1 day to modify file2.avi to 02 Jan 13 and file3.avi to 03 Jan 13, etc.

Any ideas?

Thanks!
MoodyM is offline   0 Reply With Quote
Old Jan 3, 2013, 01:17 PM   #2
mikepro
macrumors 6502
 
Join Date: Sep 2010
You can easily do stuff like this in a script or via terminal. Not sure if you have any experience with this stuff, but in a terminal window you can use the command touch to set the timestamp of a file.

For how the command works, in terminal type:

man touch

or just google touch. (Note: Don't actually touch a man based on the command above. ) Basically it will be something like this:

touch -t 1301021052 file1.avi
touch -t 1301031052 file2.avi

will give file1 a date of Jan 2 2013 10:52 am and file2 Jan 3 2013 10:52 am
__________________
Apple stuff goes here.
mikepro is offline   0 Reply With Quote
Old Jan 3, 2013, 01:19 PM   #3
MoodyM
Thread Starter
macrumors 6502
 
Join Date: Aug 2008
Thanks, but I have over 1000 files to do!
MoodyM is offline   0 Reply With Quote
Old Jan 3, 2013, 01:29 PM   #4
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by markmcrobie View Post
Thanks, but I have over 1000 files to do!
Then a shell script that loops through the files and uses touch or SetFile would be one option. Maybe some bash expert will jump in and help you out. Or someone who's more familiar with applications that could do the same thing.
LPZ is offline   0 Reply With Quote
Old Jan 3, 2013, 01:46 PM   #5
mikepro
macrumors 6502
 
Join Date: Sep 2010
OK, describe exactly what you want to do, and maybe I can whip up a quick perl or bash script for you.

Describe in detail what you want, make sure to include stuff like
Are all of the files in the same directory?
How do you determine the timestamp for a file? Based on name? Do you really want the increment to be a day, or an hour, or what?
Does the starting date matter? Base it off of an existing file?
__________________
Apple stuff goes here.
mikepro is offline   0 Reply With Quote
Old Jan 3, 2013, 02:33 PM   #6
rockridge98
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by LPZ View Post
Then a shell script that loops through the files and uses touch or SetFile would be one option. Maybe some bash expert will jump in and help you out. Or someone who's more familiar with applications that could do the same thing.
Or just drag all the files you want to change into a folder, cd to that folder, and do
touch -t 1301031052 *.avi.
rockridge98 is offline   0 Reply With Quote
Old Jan 3, 2013, 02:47 PM   #7
MoodyM
Thread Starter
macrumors 6502
 
Join Date: Aug 2008
Basically I have 24 episodes of a TV show in a folder, episodes 1 through 24, named <tv show> Episode 1.avi and so on.

For some reason my daughter's media player/hard drive will only sort by the date of the file. Since they were all added to the drive on exactly the same date, the box just sorts them seemingly randomly.

I tried using ABFA to set the Date Created for episode 1 to Jan 1, episode 2 to Jan 2, and so on, and this worked perfectly. Trouble is I have 1000's of other shows/episodes to do!
MoodyM is offline   0 Reply With Quote
Old Jan 3, 2013, 04:30 PM   #8
pitaya
macrumors member
 
Join Date: Jun 2012
Here's an example. I don't know how consistent the numbering or filenames are, though. You'll probably have to account for some inconsistencies. Delete the 'echo' when you're ready to run it on files.

Code:
 days=1; for i in {1..20}; do echo touch -t $(date -v +${days}d -v -1y '+%y%m%d%H%M') "file${i}.avi"; days=$((days+1)); done
touch -t 1201041731 file1.avi
touch -t 1201051731 file2.avi
touch -t 1201061731 file3.avi
touch -t 1201071731 file4.avi
touch -t 1201081731 file5.avi
touch -t 1201091731 file6.avi
touch -t 1201101731 file7.avi
touch -t 1201111731 file8.avi
touch -t 1201121731 file9.avi
touch -t 1201131731 file10.avi
touch -t 1201141731 file11.avi
touch -t 1201151731 file12.avi
touch -t 1201161731 file13.avi
touch -t 1201171731 file14.avi
touch -t 1201181731 file15.avi
touch -t 1201191731 file16.avi
touch -t 1201201731 file17.avi
touch -t 1201211731 file18.avi
touch -t 1201221731 file19.avi
touch -t 1201231731 file20.avi
pitaya is offline   0 Reply With Quote
Old Jan 3, 2013, 04:51 PM   #9
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by rockridge98 View Post
Or just drag all the files you want to change into a folder, cd to that folder, and do
touch -t 1301031052 *.avi.
No, that won't accomplish what the OP wants. Please read his post carefully.
LPZ is offline   0 Reply With Quote
Old Jan 3, 2013, 08:39 PM   #10
mikepro
macrumors 6502
 
Join Date: Sep 2010
OK, whipped together a quick perl script that will hopefully do what you want. To use this, paste the following code into text edit, and save it as something like "rename.pl" in a directory of your movies. Note this will only work on files in the current directory. So, if you have a bunch of folders, you will have to copy it into each folder and run it.

To run this, start a terminal window. change to the directory where your movies are. If you don't know how to change directories in terminal, do this:
type cd
Open a finder window. Drag the folder that has your movies in it into the terminal window. That will paste the directory into the terminal. Press return. Then, type:
perl rename.pl (or whatever you named the script. Note, you remembered to copy it into this folder, right?)

*** USE AT YOUR OWN RISK ****
I suggest you make a backup copy of files first and do a couple of test runs, as it will change the dates on any avi file in this directory.

Code:
use Cwd;
use strict;

my $dir = getcwd();
#print "Dir is $dir\n";

#Read test dir contents
opendir(TESTDIR, $dir);
my @allFiles = sort readdir(TESTDIR);

#print STDOUT "Got all files:\n\t", join "\n\t",  @allFiles, "\n";

#Start date of 2013 Jan 1  
my $startDate = "0101" ;
my $startHour = 1; #1am
my $startMin = 0;
my $cnt;
foreach my $item (@allFiles){
	chomp($item);
	#Remove anything that starts with a . (gets rid of ., ..)
 	next if ($item =~/^\./);
	#print "item is $item\n";
	
	if ($item =~ /(.*)(\d+)\.avi$/ ) {
#		print "Got a match $1  and $2\n";
#		push (@renameFiles, $item) ;
		$startMin++;
		if ($startMin >= 60) {
			$startHour++;
			$startMin = 0;
		}
		if ($startHour > 12) {
			$startDate++;
			$startHour=0;
		}
		
		my $ts= $startDate . sprintf ("%02d", $startHour) . sprintf ("%02d", $startMin);
		my $cmd = "touch  $ts \"$item\" ";
#		print "cmd is $cmd\n";
		system ($cmd);
	}
}
__________________
Apple stuff goes here.
mikepro is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mp3 file attributes cool11 Digital Audio 0 Oct 17, 2013 01:02 PM
PDF Attributes simple tool for editing PDF attributes Alex Aperio Lux Mac Applications and Mac App Store 0 Apr 8, 2013 04:17 PM
cannot rename file names of folders, files, or change case of file extensions Sossity Mac Basics and Help 8 Apr 2, 2013 05:38 AM
Remove/change folder attributes, not just make visible? lokiju OS X 0 Aug 21, 2012 01:23 PM
Cannot open lock in Info window or change any file attributes desertman Mac OS X 10.7 Lion 0 Jul 17, 2012 02:10 PM

Forum Jump

All times are GMT -5. The time now is 08:45 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC