Hello. My latest project has me with the need for the following script. Basically, any directory that includes a .jpg file needs to also have a ".picture" file created (if it doesn't exist). Here's an example of what I need.
In this example, I want to recursively scan all directories in /mnt/user/Pictures/, and create the .picture file in any directory that has a .jpg file within it (/mnt/user/Pictures/2011/Hawaii - 2011/, for example, does not include a .jpg file). The only directory that would need the .picture file in this example would be /mnt/user/Pictures/2012/Mammoth - family - 2012/. This .picture file is an empty dummy file, and can created as simply as "echo > .picture".
I don't mind recreating the .picture file in each directory, regardless of if it already exists or not. I thought it might be cleaner to only create it if it's needed, but it's not that big of a deal to recreate it each time regardless.
Any thoughts on the code for this script? I started going down the path of using:
find /mnt/user/Pictures/ -name \*.jpg -print
... however, I quickly hit a brick wall after that.
When I try this solution, I get the following error:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
When I try this solution, it doesn't seem to copy the .picture files to the folders. It seems to finish fine, but none of the folders have the .picture file. I tried changing the touch "$FOLDER"/.picture command to echo $FOLDER, and nothing was echo'd.
I'm still getting the same error. It seems to work, however it fails at a certain point. Is there any way to output what might be going on when it fails?
BTW, try fixing your directory names before processing, because Linux really doesn't like many of the special characters there (i.e. quotes, spaces etc).