{"id":4824,"date":"2009-10-25T09:23:58","date_gmt":"2009-10-25T13:23:58","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=4824"},"modified":"2009-10-25T09:23:58","modified_gmt":"2009-10-25T13:23:58","slug":"renaming-files-to-include-datestamp","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2009\/10\/25\/renaming-files-to-include-datestamp\/","title":{"rendered":"renaming files to include datestamp"},"content":{"rendered":"<p>My Marantz PMD-620 has a reliable internal clock, and stamps the files with the time that recording stopped. File times are remarkably fragile, so I wanted to make sure that the times were preserved in the file name. Perl&#8217;s rename utility does this rather well, as it allows you to use arbitrary code in a rename operation. So:<\/p>\n<p><code>rename -n 'use POSIX qw(strftime); my $mtime=(stat($_))[9]; s\/.WAV$\/\/; $_ .= strftime(\"-%Y%m%d%H%M%S\",localtime($mtime)); s\/$\/.WAV\/;' *.WAV<\/code><\/p>\n<p>which, for files 1007.WAV and 1008.WAV recorded last night, results in:<\/p>\n<p><code>1007.WAV renamed as 1007-20091024192436.WAV<br \/>\n1008.WAV renamed as 1008-20091024193438.WAV<\/code><\/p>\n<p>To actually rename the files, remove the <code>-n<\/code> from the command line. I left it in so you couldn&#8217;t blame me for b0rking up your files if you typed first, thought later.<\/p>\n<p>There are probably smarter ways to handle the file extension. This works for me. Perfection comes later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My Marantz PMD-620 has a reliable internal clock, and stamps the files with the time that recording stopped. File times are remarkably fragile, so I wanted to make sure that the times were preserved in the file name. Perl&#8217;s rename utility does this rather well, as it allows you to use arbitrary code in a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[175,187,1149,2023],"class_list":["post-4824","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-date","tag-perl","tag-pmd620","tag-rename"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-1fO","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/4824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=4824"}],"version-history":[{"count":1,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/4824\/revisions"}],"predecessor-version":[{"id":4825,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/4824\/revisions\/4825"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=4824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=4824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=4824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}