I'm making a little conversion script in Zenity, but have noticed that ctmconv won't allow spaces in a filename. Can I get rid of spaces in the input filename?
#!/bin/bash
cd ~/Desktop
file="$(zenity --title "3D Converter: Select a File to convert" --file-selection --file-filter=""*.ctm" "*.ply" "*.stl" "*.3ds" "*.dae" "*.obj" "*.lwo" "*.off"")"
filetype=$(zenity --list --title="Select File Type" --text="file types\ selection" --column="Select" --column="File Type" --radiolist false 3ds false ctm false dae false lwo false obj false off false ply true stl false wrl)
szSavePath="$(zenity --file-selection --filename="${file%%."${file##*.}"}"."$filetype" --save --confirm-overwrite)"
# szSavePath="$(zenity --file-selection --filename="out"."$filetype" --save --confirm-overwrite)"
ctmconv "$file" $szSavePath
zenity --info --text "Conversion Completed"
The above script gets the file to be converted, then asks for the filetype to convert to. It then replaces the original filetype with the new one and passes the result to ctmconv. Probably a messy way to do it, but hey ho! I'm new to this.
ctmconv just falls over if "$file" is "model rail", but is fine if it is just "model"
ctmconv model\ rail.obj model\ rail2.ply
.I don't havectmconv
or any sample files so it would be hard for me to test. Also, have you read the man page forctmconv
? Maybe it has suggestions for it"$file"
is properly quoted, which is good, but you didn't quote$szSavePath
that could be an issue there as well.--file-filter
quoting is a bit off. Why is there a""
at the start?