I am currently using OpenBSD 5.5-release.Whenever I copy files or directories from my USB device to the local HDD, the names of the copied files have all become uppercase.What causes it?How do I fix it?
Names of copied files from USB device to HDD have all become uppercase. How to fix it?
filenames;openbsd;removable storage;fat32
You can fix it (each time it happens) with this command:find local_directory_name -depth -exec sh -c 'dir=$(dirname $0); FILE=$(basename $0); lowfile=$(echo $FILE | tr A-Z a-z); if [ $lowfile != $FILE ]; then mv $0 $dir/$lowfile; fi' {} ;Type this all as one line (replacing local_directory_namewith the name of the directory to which you copied the files).You can break it into multiple lines by inserting backslashes.Or you can put the part after sh -c into a script file.This enumerates all the files in the directory (including subdirectories, recursively)and executes the given commands on each one.-depth makes it work bottom-up, so it processes all the entries in a directorybefore it processes (renames) the directory itself.Each filename (relative path starting from local_directory_name) is broken downinto a directory portion and a plain filename (just the bottom component).Then the filename is converted from upper case to lower case.If this is different from the existing filename,it renames the file to the lower-case name.I added this check to prevent the diagnostic messages you would otherwise getfrom trying to rename a file to itself, which would happen if you had a filewhose name contained no letters (i.e., was numerals and special characters only).Or, for that matter, if you had a file whose name contained no capital letters.Afterthought:another way to avoid mv 123 123 errors is to add -name *[A-Z]* after -depth,which tells find to process only names that contain at least one capital letter.