2024-08-18, 09:49 AM
I used the following sh script enstead of 3-6 steps:
You need to put all your files in the "data" folder. After that you need to run this script with sh. This script will replace "_" with " " in all file names . Move each file to a folder with the same name and rename all files to folder.jpg. And perform the action described in step 6.
If you have Linux, just open the convol. If you have Windows, you will have to install either WSL https://learn.microsoft.com/en-us/windows/wsl/install or some program that has a bashor sh console, for example git.
Code:
#!/bin/sh
mkdir data_out
cp data/* data_out
cd data_out
find . -depth -name '*_*' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr _ ' ')" ; done
find . -name "*.jpg" -exec sh -c 'NEWDIR=`basename "$1" .jpg` ; mkdir "$NEWDIR" ; mv "$1" "$NEWDIR/folder.jpg" ' _ {} \;
find . -type d -maxdepth 1 -exec sh -c 'NEWDIR=`echo $1 | cut -b 3` ; mkdir "$NEWDIR" ; mv "$1" "$NEWDIR" ' _ {} \;
You need to put all your files in the "data" folder. After that you need to run this script with sh. This script will replace "_" with " " in all file names . Move each file to a folder with the same name and rename all files to folder.jpg. And perform the action described in step 6.
If you have Linux, just open the convol. If you have Windows, you will have to install either WSL https://learn.microsoft.com/en-us/windows/wsl/install or some program that has a bashor sh console, for example git.