recursive touch

i just moved a bunch of media files from one device, to the other, and the file creation dates for a small number of my directories (and their contents) moved a few years into the future.

this problem smelled like a python 1 liner; i came pretty close – highlight to see the code:


import os, sys, subprocess

for d,s,fs in os.walk(sys.argv[1]):
    for p in (s+fs):
        subprocess.call(["touch",os.path.join(d,p)])

(source online, in case I improve it)


[More programming riddles]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s