Sorry I am not sure if I ask in the right place. I have a problem on metadata.
Folder0
├ Folder1
│ ├ Folder1.png
│ └ Other files
├ Folder2
│ ├ Folder2.png
│ └ Other files
└ Folder3
├ Folder3.png
└ Other files
To
Folder0
├ Folder1
│ ├ Folder1.png
│ ├ Cover.png
│ └ Other files
├ Folder2
│ ├ Folder2.png
│ ├ Cover.png
│ └ Other files
└ Folder3
├ Folder3.png
├ Cover.png
└ Other files
Is it possible to run a command line or if any software can help me duplicates the *.png in different subfolders to another png and rename it to Cover.png? Will be the best to ignore if Cover.png exists.
That will save me a lot of time since I have over 2000 folders like this.
Thanks for the help.
This can be done using Exiftool using this command
exiftool -r -ext png -o . -Filename=%d/cover.png /path/to/directories/
Exiftool will recursively read all the directories looking for PNG files. When it encounters one, it will create a copy named cover.png. If the cover.png already exists, exiftool will display 1 files weren't updated due to errors but will continue. If there are multiple PNG files, only the first one it reads will be copied and the others will return the above error.
Breakdown:
-r (recurse) option - Recurse through subdirectories
-ext png - Process only PNG files
-o. - Set the output file or directory name. When using the Filename tag (next option in the command), this causes the file to be copied instead of recreated in the output directory. The dot is used as a dummy argument in this cases because the use of the Filename tag overrides the output directory used here
-Filename=%d/cover.png - This will be the name used by the previous -o option. The %d is the directory of the file that is being processed (copied), which completes the target path to the new cover.png file.
/path/to/directories/ - replace this with the path to the top level of the directory tree you want to process. If you have CDed into the top directory, use a dot . to represent the current directory.
Related
I have a .txt list of filenames that I would like to copy into a new folder. The filenames take the form: 0-01-199898988999.mp4. I can use the list of file names to copy files into a new folder using the following code.
cp `cat list.txt` new_folder/
However, this only works when the files I want to copy, the .txt file, and the new folder are all in the same directory, and all of my files to copy are organized into subfolders within the directory.
FolderA
->list.txt
->new_folder
->SubA
-->0-01-199898988999.mp4
-->0-02-199898988999.mp4
-->0-03-199898988999.mp4
->SubB
-->0-04-199898988999.mp4
-->0-05-199898988999.mp4
-->0-06-199898988999.mp4
-->0-06-199898988999.mp4
How can I modify the code to search through the subdirectories of folder A?
I've tried using --parents, but it hasn't worked.
cp -v --parents `cat list.txt` /new_folder
I've been searching around for answers, but most versions of this problem involve a list with the unique directory names for each file (which I don't have), copying all the files within the subdirectories, or searching by extension instead of file name.
I have files in a directory, with a pattern in the filename ("IMP-"). I need to copy the files from the directory A to the directory B. But I also keep the files in the directory A. So in order to copy only the new files in directory B, I need, first to list each time I do a copy, the filenames in a text file (list.txt), and then to copy only the files that aren't listed in the text file.
exemple
Directory A (/home/ftp/recep/)
files, for example can be :
/home/recep/IMP-avis2018.txt
/home/recep/IMP-avis2018.pdf
/home/recep/IMP-avis2017.jpg
/home/recep/IMP-avis2017.pdf
Directory B (/home/ftp/transfert/)
In need to copy all files with IMP* to directory B (/home/ftp/transfert/).
And when a new file is receive in drectory A, I need this file, and only this file, to be copied in directory B (where files only stay 2 hours max)
I tought maybe I could do something with rsync, but I could'n find an adequate option.
So maybe it could be a bash script.
Actions would be :
have a simple basic text file containing already proceed files (for example liste.txt)
find files in directory A containing pattern IMP
for each of these files, read the liste.txt file and if the file is not listed in liste.txt, copy it to the directory B
You could try the option -n. The man page says:
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)
So
cp -n A/* B/
should copy all files from A to B, except those that are already in B.
Another way would be rsync:
rsync -vu A/* B/
This syncs the files from A to B and prints the file that were actually copied.
I'd like to zip a folder, but zip skips files.
Folder structure is:
main_folder > sub_folder > file2.sql
file11.txt
file12.sql
Main_folder contains sub_folder and two files, subfolder contains one file.
When i use
zip -r $path *
i receive .zip file which contains everything except file11.txt. I tried various options but have not solved the problem. Zip makes correct structure and takes every single file except files from main_folder.
could you try this;
zip -r your.zip * -x file11.txt
man zip;
-x files
--exclude files
Explicitly exclude the specified files..
I have a plain text file containing names of hundreds of files with path relative to a home directory (can be made absolute path, if needed) in various sub-directories. The home directory contains multiple directories, and thousands of files. I need to create another directory copying the files in the list, while maintaining their directory structure in the destination.
Example:
Source folder:
/home/a/
file1.jpg
file2.jpg
file3.jpg
/home/b/
file4.jpg
file5.jpg
file6.jpg
File List: (plain text, in /home/)
./a/file2.jpg
./b/file5.jpg
Expected Result:
/home/dest/a/
file2.jpg
/home/dest/b/
file5.jpg
Tried cp with various modifications from various questions on stackoverflow, but got a flat folder structure in the result every time.
Using bash on OS X Terminal
Please tell how this can be done.
You can use rsync:
rsync --relative --files-from file-list.txt /home /home/dest
Hi when I tried to transfer the contents of a folder ( The folder has several subfolders and few files) using MQFTE ftecreatetransfer command, Not only the few files in the folder but also the contents of the subfolder are transferred to destination. The same subfolders are created in destination and the contents are transferred. Is there a way to avoid the files from subfolders being transferred ?
As per this page in the Infocenter:
When a directory is specified as a source file specification, the
contents of the directory are copied. More precisely, all files in the
directory and in all its subdirectories, including hidden files, are
copied.
However, it looks like they anticipated your question because the page recently added this clarification:
For example, to copy the contents of DIR1 to DIR2 only, specify
fteCreateTransfer ... -dd DIR2 DIR1/*
So instead of specifying the folder, add the wild card to the end and you get just the files in the top level of that folder. (Assuming of course that you do not also use the -r option!)