PDA

View Full Version : App to copy files in alphabetical order, or special modify mod. date


Ranguvar
2nd September 2008, 17:48
My PSP, annoyingly enough, sorts files in the official image viewer by modification date. Explorer doesn't copy first a.jpg, then b.jpg, etc., it seems to copy completely out of order (perhaps for performance?). So, things like comics or converted eBooks end up completely out of order.

Is there a simple (preferably free) app that can either copy each file in alphabetical order, or one that can go through and change the modification dates so that the first file is the "oldest", down to the last?

Thanks.

neuron2
2nd September 2008, 18:11
Why do you care what order they are copied in? You can set a sort option on the folder. Your problem is not clear?

Ranguvar
2nd September 2008, 18:12
If the second image in a series is copied before the first, the PSP will list the files beginning with the second one, not the first. There is no option to sort alphabetically, it's "stuck" on sorting by last modified, from oldest to newest.

neuron2
2nd September 2008, 20:11
Write a DOS batch file to sort and copy.

RunningSkittle
2nd September 2008, 21:33
explorer can just sort them *after* you copy them

Ranguvar
2nd September 2008, 21:36
explorer can just sort them *after* you copy them

But it doesn't really sort them... it just changes the view.

RunningSkittle
2nd September 2008, 21:50
So the problem is with your psp...

Explorer DOES copy things in alpha-numeric order, based on file names.

fibbingbear
2nd September 2008, 21:58
Hi Ranguvar. Here's a simple python script that will change the modification times to match the alphabetical order of the files (first file is assigned a date sometime in 1969, and each new file is assigned a date 1 second later). There may be shorter/more efficient ways to do this, but I think this will work. Install python and save this to a file like "changemod.py", and invoke it on the commandline like "python changemod.py DIR", where DIR is the directory of stuff that you want to change the access times. Note that it's recursive so it'll affect subdirectories. It sorts based purely on the entire path, so things like directories are not necessarily placed out in front. I only tested it on Ubuntu, but I bet it will work for Windows.

#!/usr/bin/env python

import os, sys

def allfiles(d):
result = [ ]
for (root, dirs, files) in os.walk(d):
result.extend(map(lambda f: os.path.join(root, f), files))
return result


if __name__ == "__main__":
try:
inputdir = sys.argv[1]
allf = allfiles(inputdir)
allf.sort()
for (index, fname) in enumerate(allf):
# +1 since Ubuntu didn't recognize 0 as a valid timestamp
os.utime(fname, (index + 1, index + 1))

except:
print "Usage: %s INPUT_DIR" % sys.argv[0]
sys.exit(1)

Ranguvar
2nd September 2008, 22:46
So the problem is with your psp...

Explorer DOES copy things in alpha-numeric order, based on file names.

It does not. It says it does, but often it does not, unless you manually copy one file at a time.

@fibbingbear: Thanks very much, I'll give it a go :)

Dr.Khron
3rd September 2008, 17:13
If you want a GUI, I'm pretty sure you can do this with Total Commander.

http://www.ghisler.com/


It's not free, though, its trial-period shareware.

Ranguvar
3rd September 2008, 17:48
Found an odd thing that solved my problems - if you copy the files to the PSP normally, and then cut+paste from one directory on the PSP to another, they will cut+paste in the right order, meaning correct modification dates.

Woot!