Tag: batch

How a batch file be converted to run on Linux?

Posted by – Juli 7, 2011

Question by Ray D: How a batch file be converted to run on Linux?
I need some help with running a batch (bat.) using something other than windows, (MacOSX or linux ubuntu) I know that the file can’t simply be run but it can be converted to do so, however I have no idea how to do this.

I have the actual file that I need converted and I will be happy to give it to anyone interested in helping me with this problem.

Please help me out :)

Best answer:

Answer by JD
Sounds like you want a shell script.

http://www.freeos.com/guides/lsst/

Give your answer to this question below!

How to batch repair file and folder names encoding on windows after a windows->linux file transfer?

Posted by – Mai 7, 2011

Question by Louvi D: How to batch repair file and folder names encoding on windows after a windows->linux file transfer?
For examples, folders named “Équipement” are now named “équipement”. I guess linux changed the ISO encoding to UTF-8 one. Anyone know a way to fix it?

Best answer:

Answer by rlfwolf
Assuming you want to convert the filenames from ISO to UTF8 then here is a possible solution. Open a shell and cd into the base of the directory structure you want to convert. Then paste the following in a single line first:
for name in `find . -depth `; do new_name=`echo $name | iconv -f ISO-8859-1 -t UTF-8`; [ "$new_name" != "$name" ] && echo “$name => $new_name”; done

Once you’ve verified that it’s going to do the right thing, then paste and execute this:
for name in `find . -depth `; do new_name=`echo $name | iconv -f ISO-8859-1 -t UTF-8`; [ "$new_name" != "$name" ] && mv “$name” “$new_name”; done

If you are more comfortable working with a shell script in a file, here’s the same thing broken out to separate lines you can put in a file to execute. Don’t forget to chmod it after you create it.
#!/bin/sh

for name in `find . -depth `; do
new_name=`echo $name | iconv -f ISO-8859-1 -t UTF-8`
# new_name=`echo $name | iconv -f UTF-8 -t ISO-8859-1`
if [ "$new_name" != "$name" ]; then
echo “$name => $new_name”
# mv “$name” “$new_name”
fi
done
## END SCRIPT

Start out with the move (mv) line commented out to make sure it’ll do the right thing before it changes anything. Then, uncomment that line and run again to actually rename the files. You can reverse the conversion (UTF-8 to ISO-8859-1 instead of ISO-8859-1 to UTF-8) by switching the parameters for the iconv command. I’ve put the commented line so you can swap between the two options. Just comment out one or the other.

Good luck.

Give your answer to this question below!


Powered by Yahoo! Answers

Seite 1 von 3123