Solutions Log by Dan Reiland

25Aug/090

Mirror a Directory Structure Using the Command Line

Issue:
You need to mirror the directory structure (but not contents) for a tree.

Resolution:
Execute the following command from the root of your source directory. Adjust the destination variable to suit your tastes: %i will match the first token, %j the second, %k the third, and %l will match everything else.

for /F "tokens=1,2,3* delims=\" %i in ('dir /Ad /B /N /S') do mkdir t:\dest\%l

Reference: http://www.dostips.com/DtTipsStringManipulation.php

24Jun/090

Convert text file to UTF-8 encoding from the shell

1
for f in *.txt; do iconv -f mac -t utf-8 "$f" >"$f.utf8"; done

Note:
-f Input file encoding type
-t Output file encoding type

Reference: http://manual.macromates.com/en/saving_files.html