The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 02-11-2009
handband2 handband2 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
Quote:
Originally Posted by vgersh99 View Post
you don't need the 'if [ -e "*.doc" ]' (and the matching 'fi) - you will not go into the outter 'for' loop if there's nothing match against '*.doc'
Actually I need to identify what type of files exist within the folder or it makes necessary folders:
Code:
#! /bin/bash
##
soffice -headless -accept="socket,port=8100;urp;"
for file in *.doc
	do
	mkdir ./ODT
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./ODT/"${file}".odt
	for i in *.odt; do j=`echo $i | sed 's/doc.odt/odt/g'`; mv "$i" "$j"; done    
done

for file in *.xls
	do
	mkdir ./ODS
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./ODS/"${file}".ods
	for i in *.ods; do j=`echo $i | sed 's/xls.ods/ods/g'`; mv "$i" "$j"; done    
done

for file in *.ppt
	do
	mkdir ./ODP
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./ODP/"${file}".odp
	for i in *.odp; do j=`echo $i | sed 's/ppt.odp/odp/g'`; mv "$i" "$j"; done    
done

for file in *.odt
	do
	mkdir ./DOC
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./DOC/"${file}".doc
	for i in *.doc; do j=`echo $i | sed 's/odt.doc/doc/g'`; mv "$i" "$j"; done    
done

for file in *.ods
	do
	mkdir ./XLS
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./XLS/"${file}".xls
	for i in *.xls; do j=`echo $i | sed 's/ods.xls/xls/g'`; mv "$i" "$j"; done    
done

for file in *.odp
	do
	mkdir ./PPT
	python /opt/DocumentConverter/DocumentConverter.py "${file}" ./PPT/"${file}".ppt
	for i in *.ppt; do j=`echo $i | sed 's/odp.ppt/ppt/g'`; mv "$i" "$j"; done    
done