Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Friday, April 24, 2020

Shell tricks

Posting this for my own reference.

How to rename the full name of the files by replacing '/' (slash) with '_' (underscore) using zmv in zsh


$ zmv '(**/)(*.txt)' '${1//\//_}${2}'

The first pattern (**/) ensure that you go inside all subdirectories recursively,
the second pattern (*.txt) restricts this operation to only those files ending with ".txt".

${1//\//_} ensure that you replace every '/' in the first pattern to '_' .

Wednesday, April 09, 2008

Duplex printing script

Well,
Our department printer by default runs in single side printing mode. This causes a lot of paper wastage. I finally sat down and wrote a shell script which will takes one PDF file as an input and outputs two PDF files. One with all odd-pages. Another with all even pages in reverse order so that output papers from odd-page printing can be directly fed to input tray. Of course, this requires a bit of manual intervention, but it is not a big price to pay for saving paper ( and saving trees ).
Here is a link to the script :
http://sbjoshi.googlepages.com/duplexprinting.sh

Please let me know if any bug is found in the script or if you want to suggest some improvements.
--Saurabh Joshi