# Rename File in File System

**URL:** <https://forums.creativeclouddeveloper.com/t/rename-file-in-file-system/3303>\
**Category:** UXP Plugin API\
**Created:** [July 15, 2021, 2:50pm UTC](https://forums.creativeclouddeveloper.com/t/rename-file-in-file-system/3303 "2021-07-15T14:50:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jens\_z](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jens\_z](https://forums.creativeclouddeveloper.com/u/Jens_z)\
**Post date:** [July 15, 2021, 2:50pm UTC](https://forums.creativeclouddeveloper.com/t/rename-file-in-file-system/3303/1 "2021-07-15T14:50:30Z")

</div>

Hi there,  
I would like to save a TIF file but with extension “.abc” instead of “.tif”.  
I’m saving the TIF using fs.getFileForSaving(“MyFile. **abc** ”), but PS is clever and nevertheless saves it as MyFile. **tif**.

As workaround I’m trying to save the file as \*.tif and rename it afterwards using the UXP API function [renameEntry()](https://www.adobe.io/xd/uxp/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#renameentryentry-newname-options) using following code:

```auto
var MyFolder = await require('uxp').storage.localFileSystem.getFolder(); // User needs to select folder
var entry = await MyFolder.getEntry("MyFile.tif"); // Loads mentioned file as "entry"
await MyFolder.rename(entry, "MyFile.abc"); // Renames the entry

```

If I debug that I can see that the first 2 lines are working well, and that “entry” properly contains the file “MyFile.tif”.  
But the rename() itself does not do anything.

Does anyone have a idea what the problem could be? Do I need a “Session Token” here as well as for the saving?  
Or maybe someone has an idea how to tell PS directly to save a file with a custom extension.

Kind Regards

---

<div class="post-metadata">

**Author:** ![Jens\_z](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jens\_z](https://forums.creativeclouddeveloper.com/u/Jens_z)\
**Post date:** [July 23, 2021, 6:16pm UTC](https://forums.creativeclouddeveloper.com/t/rename-file-in-file-system/3303/3 "2021-07-23T18:16:05Z")

</div>

Hi there,  
final update on that:

Since the [renameEntry()](https://adobe-photoshop.github.io/uxp-api-docs/docs/media/uxp/module/storage#module-storage-folder-renameentry) function is not yet available in the official PS version, I’ve now solved it using moveTo() within the same folder with renaming as workaround:

```auto
  var persistentFolderToken = await localStorage.getItem("persistent-token"); 
  var folder = await require('uxp').storage.localFileSystem.getEntryForPersistentToken(persistentFolderToken);
  var entry = await folder.getEntry("MyFile.tif"); 
  await entry.moveTo(folder, { newName: "MyFile.abc", overwrite: true })

```

btw: there is a typo in the [documentation](https://www.adobe.io/photoshop/uxp/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/#movetofolder-options):  
it says

```auto
await someFile.moveTo(someFolder, {newName: 'novel.txt', {overwrite: true})

```

but should be

```auto
await someFile.moveTo(someFolder, {newName: 'novel.txt', overwrite: true})

```
