pre-Git files/Garmin Log renaming.cc.rb
# Copy and rename files from Year Downloads to Year Massaged folder and create list of those new files
Copy and rename files from Year Downloads to Year Massaged folder and create list of those new files
Copy and rename files from Year Downloads to Year Massaged folder and create list of those new files
def copyMotionX(newFiles,baseFolderGPX, folderDownload)
  puts "165. Copying gpx file from #{folderDownload} to Massaged Folder and adding to newFiles, the list of files to be processed."
  i = 0
  folderNew = ""
  today = Time.now.strftime("%Y%m%d")
  Find.find(folderDownload) do |fx|
   next if !File.file?(fx) 
    Find.prune if File.extname(fx) != '.gpx' 
    yearFile  = File.basename(fx)[0,4]
    fileshortnew = dotInName(fx,yearFile)
    folderNew = "#{baseFolderGPX}#{yearFile} Massaged" 
  end 
  puts "\n159. Copying and renaming finished. #{i} gpx files copied to #{folderNew}.\n\n" 
  return newFiles   
end
def copyMotionX ( newFiles , baseFolderGPX , folderDownload ) puts "165. Copying gpx file from #{folderDownload} to Massaged Folder and adding to newFiles, the list of files to be processed." i = 0 folderNew = "" today = Time . now . strftime ( "%Y%m%d" ) Find . find ( folderDownload ) do | fx | next if ! File . file? ( fx ) Find . prune if File . extname ( fx ) != '.gpx' yearFile = File . basename ( fx ) [ 0 , 4 ] fileshortnew = dotInName ( fx , yearFile ) folderNew = "#{baseFolderGPX}#{yearFile} Massaged" end puts "\n159. Copying and renaming finished. #{i} gpx files copied to #{folderNew}.\n\n" return newFiles end
Copy and rename files from Year Downloads to Year Massaged folder and create list of those new files
Copy and rename files from Year Downloads to Year Massaged folder and create list of those new files
# puts "121. fx: #{fx}. File.file?(fx): #{File.file?(fx)}. " # the directory we're looking in is added to the fx list, so skip it. # Was  Find.prune if … which didn't work # puts "123. fx: #{fx}" # Find.prune if  File.exist?(fx)  # checking if file to be processed exists. Probably not needed now as only working with a list of existing files # get errors trying to process other files on card. # puts "127. fx: #{fx}. File.basename(fx): \n" #{File.basename(fx)} # Establish file name # fileshortnew = "#{yearFile}.#{File.basename(fx)[4,2]}.#{File.basename(fx)[6,2]}" #  moved to method # puts "134. File.basename(fx, \".TEMP.gpx\"): #{File.basename(fx, ".TEMP.gpx")}." # puts "135. File.basename(fx): #{File.basename(fx)}. yearFile: #{yearFile}. fileshortnew: #{fileshortnew} \n" # MIGHT MOVE THIS FROM THE TWO DEFS # puts "182. fnew: #{fnew}  ============================\n" # puts "137. today: #{today}==File.basename(fx, \".TEMP.gpx\"): #{File.basename(fx, ".TEMP.gpx")}" # THIS IS ALL WRONG FOR THE FILE NAME I'M USING. CAN'T CHANGE FILE NAME BECAUSE MAY HAVE MULTIPLE DOWNLOADS FOR THE DAY # if today==File.basename(fx, ".TEMP.gpx") #      # puts "140 fx: #{fx}. " #      # Not clear why originally was using timeshifted, seems should just be original filename with TEMP added #      # fileshortnew = timeshifted.strftime("%Y.%m.%d") + ".TEMP" # formatting filename #      fileshortnew = dotInName(fx,yearFile) + ".TEMP"  #      #  year is timeshifted. Not sure whey  #      # fnew = "#{baseFolderGPX}#{year} Massaged/#{fileshortnew}.gpx" #      fnew = "#{folderNew}/#{fileshortnew}.gpx" #      # fileTEMP = true #    else # all but today's file #      fnew = "#{folderNew}/#{fileshortnew}.gpx" #      # puts "150. fnew: #{fnew}." #      # fileTEMP = false #    end # today==. Add TEMP to today's files #    if !File.exists?(fnew) #      newFiles << fnew #      FileUtils.cp(fx, fnew)  #      i =+ 1 #    end  # !File.exists?(fnew). add to newFiles  # Find.find(folderDownload) do |fx|. The basic grind # puts "\n160. newFiles: #{newFiles}.\n    Not exactly the same as newFiles below."
newFiles
<not_specific>
baseFolderGPX
<not_specific>
folderDownload
<not_specific>