Sopi (Sort Pictures) is a Julia simple program that takes a list of files from my camera (with extension "JPG") and move them in a directory tree named after the date, also appending the hour of the shot to the filename itself.
# ____ _ # / ___| ___ _ __ (_) # \___ \ / _ \| '_ \| | # ___) | (_) | |_) | | # |____/ \___/| .__/|_| # v°0.1 |_| # Sat 10 Oct 21:49:49 CEST 2020 # F.P. Laussy - fabrice.laussy@gmail.com # # Sopi sorts jpg files in a directory tree named after the dates # at which the pictures have been taken (after their exif data) # (`sopi' stands for Sort Pictures) # This list the filenames of JPG files to process (in current path) lfn=filter(x->occursin("JPG",x), readdir()); # Starting print("Hi there! Sopi working with "*string(length(lfn))*" files...\n") # This returns a vector with date and time from the exif data function datemy(fn) mdata = read(`exiftool $fn`,String) sdata=split(mdata,"\n") spdata=split(sdata[findall( x -> occursin("Date/Time Original", x) , split(mdata,"\n"))[1]]," ") [spdata[end-1],spdata[end]] end # This collects all the dates and times to process and transform into a matrix alltimes=permutedims(reduce(hcat,[datemy(i) for i in lfn])) # Keep unique days uniquetimes=(x->replace(x, ":"=>"/")).(unique(alltimes[:,1])) # This creates the directory tree lmonths=["/01/" "/January/"; "/02/" "/February/"; "/03/" "/March/"; "/04/" "/April/"; "/05/" "May"; "/06/" "/June/"; "/07/" "/July/"; "/08/" "/August/"; "/09/" "/September/"; "/10/" "/October/"; "/11/" "/November/"; "/12/" "/December/"] for i=1:12 global uniquetimes=(x->replace(x,lmonths[i,1]=>lmonths[i,2])).(uniquetimes[:,1]) end print("Working with "*string(length(uniquetimes))*" directories...\n") mkpath.(uniquetimes) print("Moving files!\n") # This puts the files in pla for i=1:length(lfn) dest=split(alltimes[i,1],":") mv(lfn[i],dest[1]*lmonths[:,2][parse(Int64,dest[2])]*dest[3]*"/"*replace(lfn[i],".JPG"=>"-")*alltimes[i,2]*".jpg") end print("Done.\n")