Skip to main content

Hi!

 

My knowledge of FME is very limited and I'm only familiar with the program.

 

I have several folders containing thosands of .jpgs. I want to rename adding a prefix. I've seen other threads like this but they don't help me at all since I know nothing of the program. This one ehttps://knowledge.safe.com/questions/41624/is-there-a-quick-way-to-rename-files.html] for example uses a tool named filecopy but I can't get it too work. Any suggestions?

Hi @makshmellow,

I simulated here your case with a folder and it was contained 6 files .PNG.

The transformer AttributeManager was used to add a prefix ( SAFE_ ) in the attribute fme_basename:

The Writer FILECOPY was inserted in my Workspace and the mode = Move.

 

 

workspace-add-prefix.fmw

Attached the Workspace

Thanks,

Danilo


Hi @makshmellow, you can use a Directory and File Pathnames (PATH) reader and a File Copy writer to add a common prefix to all JPG file names, which are saved under a specific directory and its subfolders.

  1. Add a PATH reader and a File Copy writer for the same Dataset (a directory that contains subfolders containing JPG files) to the workspace, configure the reader/writer parameters as shown in the screenshots. You can also modify the parameters via the Navigator window after adding the reader and writer, if necessary.

  2. On the Canvas, connect between {the PATH reader feature type and the File Copy writer feature type}, {source file path ('path_unix') and 'filecopy_source_dataset'}, and {source directory path ('path_directory_unix') and 'filecopy_dest_dataset'}. With a Windows machine, 'path_windows' and 'path_directory_windows' are also available.
  3. In the File Copy writer feature type, set a string concatenating your desired prefix and 'path_filename' (i.e. original file name) to 'filecopy_dest_filename' (destination file name).

That's it.

Note: Since it would be so troublesome to restore the original file names if it failed, it would be strongly recommend to make a backup of the root directory and its descendant folders/files beforehand.


Hi @makshmellow,

I simulated here your case with a folder and it was contained 6 files .PNG.

The transformer AttributeManager was used to add a prefix ( SAFE_ ) in the attribute fme_basename:

The Writer FILECOPY was inserted in my Workspace and the mode = Move.

 

 

workspace-add-prefix.fmw

Attached the Workspace

Thanks,

Danilo

Hi Danilo,

 

I can not seem to find the workbench, would you mind reuploading it?

 

Thanks in advance.


Reply