From 0fd9ce6154c4743c0c29b09bd91a56241b2eac08 Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Tue, 13 Dec 2022 12:15:20 -0600 Subject: [PATCH] Better commenting --- ren-from-csv.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ren-from-csv.sh b/ren-from-csv.sh index d897ffa..a8be8bc 100644 --- a/ren-from-csv.sh +++ b/ren-from-csv.sh @@ -1,11 +1,13 @@ -#!/bin/bash5 +#!/bin/bash -# Rename a set of files in current dir from .csv - portable and fairly simple +# Utility to Rename a set of files in current dir using a .csv input file - portable and fairly simple +# REQUIRES: awk, column # 2022.Dec Kingneutron # HOWTO: # cd to dir you want to work on -# Populate a temporary file with bare filenames (don't have to use ls, can use "find" or whatever) + +# Populate a temporary file with bare filenames: (NOTE don't have to use ls, can use "find" or whatever) # ls -1 >tmp.csv # Preprocess tmp file and add comma + duplicate filename: @@ -14,7 +16,7 @@ # Edit tmp file and replace 2nd filename after comma with preferred filename # IMPORTANT: Delete any lines that you DONT want renamed -# Run this script +# Then Run this script # failexit.mrg # REF: https://sharats.me/posts/shell-script-best-practices/ @@ -52,10 +54,11 @@ ls -lh $logf $errlog exit; -# PROTIP: install detox package and run that on dir 1st # detox -v $PWD # HOWTO: -# $ ls -1 >tmp.csv # populate +# cd to working dir 1st + +# $ ls -1 >tmp.csv # populate temp output file (can also use find or whatever) wallpapersden.com_olivia-taylor-dudley-2018_2160x3840.jpg watchmen-youre-locked-in-here-with-me--fark_9jLJBkZ86xroJXgJl_PxH0pBQf8.jpg we-dont-need-no-stinkin-gadgets--fark_mqkB3Y1u50LMlRwXXyDPjOkwltw.jpg @@ -66,6 +69,8 @@ xev-fark_SWJwl7Tm8mZKQydJ60dKAqVJlI0.jpg awk '{print $1",\t"$1}' tmp.csv |column -t >rename.csv #awk '{print $0",\t"$1}' tmp.csv >rename.csv +# Edit rename.csv and edit 2nd field = new filename to rename to + $ cat rename.csv we-beat-em-before-red-hat-nazis--fark_D0aakxPNV05v8A6OUS2P6AZAYms.jpg, we-beat-em-before-red-hat-naztis--fark_D0aakxPNV05v8A6OUS2P6AZAYms.jpg we-dont-need-no-stinkin-gadgets--fark_mqkB3Y1u50LMlRwXXyDPjOkwltw.jpg, we-dont-need-no-steenkin-gadgets--fark_mqkB3Y1u50LMlRwXXyDPjOkwltw.jpg