Question about moving a range of files with a Bash script
Greetings, I'm new to bash scripting. I am writing a script to help me in making gif images from a large video. I've written bash code to successfully take an input video, output 2 things: a video at the desired output size with 10 fps, and a png for each frame in that video (let's say, 59000 images) then the script watermarks all of those images.
The images are named, say, test00001.png - test59704.png Now, seeing as Nautilus chokes and dies a firey death on a folder with that many files, I want to be able to have a command where I move a subset of files to another folder. I see it taking the start frame number, the end frame number, and the folder name, and automatically running a for loop moving them all. I understand how to do that in theory, but in making my for loop, how can I preserve my incrementing number to have 5 digits? Let's say I input $START $FINISH and $DIR Code:
mkdir $DIR |
Code:
# printf "%05d" 9 |
try
Code:
mkdir $DIR |
or
Code:
for file in eval {00001..$FINISH} |
Quote:
Code:
#! /bin/bash Code:
testeval.png I think perl will do something with the leading zeros in such a context, but in shell scripts, anything that looks like a number will be turned in to a number at the parsing stage, thus you need printf to format a number in to a string with leading 0s after the fact. |
An alternative using seq:
Code:
mv $(seq -f 'test%05.0f.png' $START $FINISH) $DIR You can also create a function, accepting three arguments: the start number, the end one and the destination directory: Code:
function mvpng () { |
Quote:
|
All times are GMT -5. The time now is 11:23 AM. |