Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Attempting to have this script run through a directory and perform the operation on every file with the .tmp.tcx extension, so if I had 3 unique files with ${b}.tmp.tcx, I'm hoping for 3 unique files ${b}.tcx.

Unsure why this script ends up only outputting one file in .tcx (line 6). Seems like a problem with line 5 defining b?

#! /bin/bash

for a in *tmp.tcx; do
  if [ -f "$a" ]; then # was it a file
    b="${a%.tmp.tcx}" #set b to $a without .tmp.tcx
    xml fo -t $a > "${b}.tcx"
    mv *gmn /home/pato/garmin/tcx-output/
    mv *tmp.tcx /home/pato/garmin/tcx-output/
  fi
done
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Your first entry into the loop for the first file does the xml output for the file it finds, then copies all tmp.tcx files out of the folder. So the next go around the loop, the xml will try to process a file that is no longer there.

Try changing line 6 to

 mv $a /home/pato/garmin/tcx-output

Which will only move the file you just processed.

share|improve this answer
    
perfect - thanks paul –  jojo May 21 '12 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.