bash script to flatten a dir
This commit is contained in:
parent
bc1830a62a
commit
724cf919e4
1 changed files with 22 additions and 0 deletions
22
_src/files/flatten.sh
Executable file
22
_src/files/flatten.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set the source and destination directories
|
||||||
|
src_dir="./emojis_categorized"
|
||||||
|
dest_dir="../emojis"
|
||||||
|
|
||||||
|
# Navigate to the source directory
|
||||||
|
cd "$src_dir" || exit
|
||||||
|
|
||||||
|
# Find all files in subdirectories and loop through them
|
||||||
|
find . -type f -not -path '*/\.*' -print0 | while IFS= read -r -d $'\0' file; do
|
||||||
|
|
||||||
|
# build the new filename
|
||||||
|
filename=$(echo "$file" | sed 's/\//+/g' | sed 's/^.+/..\/emojis\//g')
|
||||||
|
echo "$filename"
|
||||||
|
echo "$file"
|
||||||
|
|
||||||
|
# # Copy the file to the destination directory with the new filename
|
||||||
|
cp "$file" "$filename"
|
||||||
|
done
|
||||||
|
|
||||||
|
# echo "Flat folder creation complete!"
|
Loading…
Add table
Reference in a new issue