Home > Software engineering >  RenameFile doubles the extension on some computers
RenameFile doubles the extension on some computers

Time:10-22

I have a simple Project running on two computers independently. It renames a bunch of files and uploads them via ftp (FluentFTP). On my development computer this works ok

img00012.jpg -> myPicture_001_summer.jpg
img00014.jpg -> myPicture_002_summer.jpg
img00015.jpg -> myPicture_003_summer.jpg
img00018.jpg -> myPicture_004_summer.jpg

on the other one it doubles the file extensions

img00012.jpg -> myPicture_001_summer.jpg.jpg
img00014.jpg -> myPicture_002_summer.jpg.jpg
img00015.jpg -> myPicture_003_summer.jpg.jpg
img00018.jpg -> myPicture_004_summer.jpg.jpg

The code I am using is essentially this:

Dim filesToCopy As New Dictionary(Of String, List(Of String))
For Each fil In files
    dim ftpFolder = calcFtpFolder(fil)             'returns e.g. "/mySubFolder/"
    dim newName = calcNewName(fil, nbr)            'returns e.g. "myPicture_001_summer"
    My.Computer.FileSystem.RenameFile(fil.FullName, newName   fil.Extension)
    filesToCopy(ftpFolder).Add(fil.DirectoryName   "\"   newName   fil.Extension)
Next fil

For Each kvp In filesToCopy
  Dim filelist = kvp.Value
  Dim remoteDir = kvp.Key
  ftp.UploadFiles(filelist, remoteDir, .....)
Next

Both computers run on an updated windows10x64. Has anyone encountered similar things? Where should I investigate?

CodePudding user response:

Probably both are like this: img00012.jpg -> myPicture_001_summer.jpg.jpg, because you have checked the "Hide extensions for known files" in one of the computers.

So, open a Windows Explorer > See/View > Options > See/View > Hide Extensions for known files (could be a little different, my language is not EN).

  • Related