-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e0ae07
commit fcf60ec
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bck/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# rename-arw | ||
**rename-arw** is a script that operates in the folder in which it is launched and ranames all the RAW files with `.ARW` extension following this path: `YYYYMMDDHHmmss-<pattern><filename>` | ||
|
||
## Description | ||
**rename-arw** is a script that operates in the folder in which it is launched and ranames all the RAW files with `.ARW` extension following this path: | ||
|
||
`YYYYMMDDHHmmss-<pattern><filename>` | ||
|
||
> `<pattern>` must be provided by user. | ||
> `YYYYMMDDHHmmss` is retrieved from the datetime metadata of the file. | ||
## Installation | ||
``` | ||
sudo mkdir -p /usr/local/bin/ | ||
sudo chmod +x /usr/local/bin/ | ||
cp rename-arw /usr/local/bin/ | ||
echo 'PATH=$PATH:/usr/local/bin/' >> ~/.bashrc | ||
``` | ||
|
||
## Usage | ||
``` | ||
cd <directory-containing-arw> | ||
rename-arw <pattern> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# Check pattern argument | ||
|
||
usage(){ | ||
echo " " | ||
echo "Usage:" | ||
echo "cd <directory-containing-arw>" | ||
echo "rename-arw <pattern>" | ||
echo " " | ||
} | ||
|
||
if [ -z "$1" ];then | ||
echo "Error!" | ||
echo "Argument <pattern> is missing." | ||
usage | ||
exit 1 | ||
else | ||
pattern=${1} | ||
fi | ||
|
||
# Check | ||
if arw_num=`ls -1|grep ARW|wc -l`; then | ||
if [ ${arw_num} -lt 1 ];then | ||
echo "Error!" | ||
echo "No .ARW file found in this folder: $PWD" | ||
usage | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Execution | ||
for i in `ls -1 *ARW` | ||
do | ||
datetime=`file -p ${i}|cut -d "," -f 13|cut -d "=" -f 2|tr ":" " "|tr -d " "` | ||
echo ${i} "--->" ${datetime}-${pattern}${i} | ||
mv ${i} ${datetime}-${pattern}${i} | ||
done |