-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstoretouch
More file actions
executable file
·63 lines (47 loc) · 1.26 KB
/
storetouch
File metadata and controls
executable file
·63 lines (47 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use File::Find;
use Data::Dumper;
use POSIX qw( strftime );
use Getopt::Long qw(GetOptions);
my $debug;
my $output = ".";
my @files;
GetOptions(
'debug' => \$debug,
'output=s' => \$output,
'help' => sub { showHelp(0) },
) or showHelp(1);
sub showHelp {
my $exitval = defined($_) ? $_ : 0;
print <<EOF;
$0 [-h|--help] [--version] [-d|--debug] [-o|--output <FILE>] [DIR]...
--help, -h : Print this help, then exit
--version : Print the script version, then exit
--output : Specify file to output script to, default is STDOUT
EOF
exit $exitval;
}
findFiles(!@ARGV ? (".") : @ARGV);
sub findFiles {find sub {push @files, $File::Find::name}, @_}
foreach(@files) {
/\.git(\/.*)?$/ && next;
!lstat && next;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= lstat;
s/\\/\\\\/g;
s/\'/\\'/g;
s/\x07/\\a/g;
s/\x08/\\b/g;
s/\x09/\\t/g;
s/\x0A/\\n/g;
s/\x0B/\\v/g;
s/\x0C/\\f/g;
s/\x0D/\\r/g;
s/([\x00-\x1F\x7F])/'\x'.sprintf("%02X", ord($1))/eg;
s/(.*)/\$\'$1'/;
print "touch -ht ". strftime("%Y%m%d%H%M.%S", localtime($mtime)). " $_\n";
}