|
| |||||||||
| Tags: document, linux, pdf, script, shell, shell script |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Shell script to add the extension to doc and pdf files
I am trying to develop a shell script which i will be using it in Linux, where i am trying to add an extension to a large number of pdf and doc files. Frankly speaking i don't have any idea about it but has some basic programming language, can anyone provide me with the code which can fulfill my requirements. |
|
#2
| ||||
| ||||
| Shell script to add the extension to doc and pdf files
If you really want to add extension to your doc and pdf files then i would suggest you to use the following code in your script and i am sure this will realy help you a lot. Code: / bin / sh for i in `ls-l | awk '(print $ 8)'` do var = $ (file $ i | grep-i pdf | awk '(print $ 2)') if [ "$ var" == "PDF"] then echo $ var; cp $ i $ i.pdf; else cp $ i $ I.doc; echo "BAD"; if; |
|
#3
| |||
| |||
| Shell script to add the extension to doc and pdf files
Thank you for replying me i had try to use the above code in my Shell script over here i am facing some issue where it copies all the files through .doc and teh code is not working for pdf files, can anyone tell me what's the exact issue with the code. |
|
#4
| ||||
| ||||
| Shell script to add the extension to doc and pdf files
Sorry i had done a very small mistake that i had inserted 2 equal sign instead of one, this is one of the reason for all the files get copy through the. Doc and not pdf files and i had made changes in the code have a look at it. Code: / bin / sh for i in `ls-l | awk '(print $ 8)'` do var = $ (file $ i | grep-i pdf | awk '(print $ 2)') if [ "$ var" = "PDF"] then cp $ i $ i.pdf; else cp $ i $ I.doc; if; |
|
#5
| |||
| |||
| Re: Shell script to add the extension to doc and pdf files
Thats very kind of you guys, from a long back i was finding for such kind of script and over here i would like to share my knowledge if you want to watch the execution traces then you have to add the following code in your script Code: $> Bash-x monscript.sh |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Shell script to add the extension to doc and pdf files" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell extension on gnome 3.2 | HangDown | Operating Systems | 8 | 06-01-2012 10:37 AM |
| PSD Shell Extension Problem Resource file C_PsdRsDll not found | TAARIQ | Operating Systems | 4 | 05-11-2010 05:12 AM |
| Cutting a file into several files using shell script | Shaan12 | Software Development | 3 | 23-10-2009 12:43 AM |
| Download GMail Drive shell extension | Techguru01 | Technology & Internet | 4 | 04-03-2009 05:48 PM |
| Script to search for and delete all files with extension xxx | Mike62 | Windows Server Help | 2 | 25-11-2006 10:58 PM |