Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active March 15, 2022 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/9067497 to your computer and use it in GitHub Desktop.
Save kou1okada/9067497 to your computer and use it in GitHub Desktop.
A touch utility for fuji xerox network scanner utility 3 (http://www.fujixerox.co.jp/download/scanner/scan3/).

scan3touch

A touch utility for fuji xerox network scanner utility 3.

This script processes files in directories that has below patterns of name:

img-[[:id:]]-[[:model:]]([[:id:]])-[[:id:]]-YYmmddHHMMSS
YYmmddHHMMSS-[[:model:]]([[:id:]])-[[:id:]]-YYmmddHHMMSS

For examples:

img-Z12345678-ApeosPort-IV C5580(123456)-1234-140101000000
20160212112954-ApeosPort-V 7080(206454)-0245-160212113032
20220315121416-Apeos C2570(538923)-0094-220315121434

Installation

  1. Install cygwin.
  2. Copy scan3touch.sh to ~/local/bin/.
  3. Copy scan3touch.bat to the directory that is configured to "fuji xerox network scanner utility 3" for saving scan files.

Usage

Run by double click scan3touch.bat which was installed with Installation section step 3.

@ECHO OFF
PATH=C:\cygwin64\bin;C:\cygwin\bin
bash -c "~/local/bin/scan3touch.sh *Apeos*|sh"
PAUSE
#!/usr/bin/env bash
# Usage: is_scan3_dir name
function is_scan3_dir ()
{
[[ -d "$1"
&& (
"$1" =~ ^img-[[:alnum:]]*-[[:print:]]*\([0-9]*\)-[0-9]*-[0-9]{12}$ ||
"$1" =~ ^[[:digit:]]{14}-[[:print:]]*\([0-9]*\)-[0-9]*-[0-9]{12}$
)
]] || return 1
}
if [ $# -eq 0 ]; then
cat<<-EOD
Usage: ${0##*/} dirs ...
A touch utility for the fuji xerox network scanner utility 3.
http://www.fujixerox.co.jp/download/scanner/scan3/
This script process files in dirs that has below patterns:
img-[[:id:]]-[[:model:]]([[:id:]])-[[:id:]]-YYmmddHHMMSS
YYmmddHHMMSS-[[:model:]]([[:id:]])-[[:id:]]-YYmmddHHMMSS
For examples:
img-Z12345678-ApeosPort-IV C5580(123456)-1234-140101000000
20160212112954-ApeosPort-V 7080(206454)-0245-160212113032
20220315121416-Apeos C2570(538923)-0094-220315121434
EOD
exit 0
fi
echo "set -x"
while [ $# -gt 0 ]; do
if is_scan3_dir "${1%/}"; then
stamp="${1%/}"
stamp=20${stamp##*-}
stamp="${stamp:0:4}-${stamp:4:2}-${stamp:6:2} ${stamp:8:2}:${stamp:10:2}:${stamp:12:2}"
echo "find \"$1\" -exec touch -d \"$stamp\" {} +"
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment