Skip to content

Windows: 10x faster shortcut creation and fixed emoji folder name issues (also fix broken shortcuts in Win) - #390

Open
Wacheee wants to merge 1 commit into
TheLastGimbus:masterfrom
Wacheee:emojisInFolder
Open

Windows: 10x faster shortcut creation and fixed emoji folder name issues (also fix broken shortcuts in Win)#390
Wacheee wants to merge 1 commit into
TheLastGimbus:masterfrom
Wacheee:emojisInFolder

Conversation

@Wacheee

@Wacheee Wacheee commented Mar 5, 2025

Copy link
Copy Markdown

When folder names contain emojis (like 💖🤖🚀), the PowerShell Shell.CreateShortcut method has an encoding issue:
https://stackoverflow.com/questions/74728834/copy-the-target-of-a-shortcut-file-lnk-when-the-target-path-contains-emoji-c

After trying different encoding and decoding methods, it was impossible to fix this issue in PowerShell.

Using FFI, which allows interaction with OS APIs (win32 in this case), turned out to be the solution.

The advantage is that it is 10x faster at creating shortcuts than using PowerShell on Windows!

Current Method -> PowerShell (105 seconds) [473 shortcuts]
image

New Method -> FFI (12 seconds) [473 shortcuts]
image

The code doesn't discard the use of PowerShell, if FFI fails to create the shortcut on Windows, it falls back to the old PowerShell method.

This fixes: #389
It also fixes: #276 (because on Windows shortcuts are created with absolute path)

@Wacheee Wacheee changed the title Windows: 10x faster shortcut creation and fixed emoji folder name issues Windows: 10x faster shortcut creation and fixed emoji folder name issues (also fix broken shortcuts in Win) Mar 5, 2025
@jazzathedev

Copy link
Copy Markdown

Tested this out, can confirm it works well, this fixed saved me from making my own tool to do this 💀

@jaimetur

Copy link
Copy Markdown

When folder names contain emojis (like 💖🤖🚀), the PowerShell Shell.CreateShortcut method has an encoding issue: https://stackoverflow.com/questions/74728834/copy-the-target-of-a-shortcut-file-lnk-when-the-target-path-contains-emoji-c

After trying different encoding and decoding methods, it was impossible to fix this issue in PowerShell.

Using FFI, which allows interaction with OS APIs (win32 in this case), turned out to be the solution.

The advantage is that it is 10x faster at creating shortcuts than using PowerShell on Windows!

Current Method -> PowerShell (105 seconds) [473 shortcuts] image

New Method -> FFI (12 seconds) [473 shortcuts] image

The code doesn't discard the use of PowerShell, if FFI fails to create the shortcut on Windows, it falls back to the old PowerShell method.

This fixes: #389 It also fixes: #276 (because on Windows shortcuts are created with absolute path)

I write you here because I don't see any other way to contact you from your forked repository (there is no discussion section enabled). I

I have an error during Copying photos but I cannot debug it more. Could you please try to point me what is happening with this log messages?

2025-03-19 05:55:14 [INFO ] - Finding albums (this may take some time, dont worry :) ...
2025-03-19 05:58:05 [INFO ] -
2025-03-19 05:58:05 [INFO ] -
2025-03-19 05:58:05 [INFO ] - Copying photos to output folder : ........................................ 0/13049
2025-03-19 05:58:05 [ERROR ] - Unhandled exception:
2025-03-19 05:58:05 [ERROR ] - type 'String' is not a subtype of type 'num'
2025-03-19 05:58:05 [ERROR ] - #0 main (file:///home/runner/work/GooglePhotosTakeoutHelper/GooglePhotosTakeoutHelper/bin/gpth.dart:423)
2025-03-19 05:58:05 [ERROR ] -

@Wacheee

Wacheee commented Mar 19, 2025

Copy link
Copy Markdown
Author

When folder names contain emojis (like 💖🤖🚀), the PowerShell Shell.CreateShortcut method has an encoding issue: https://stackoverflow.com/questions/74728834/copy-the-target-of-a-shortcut-file-lnk-when-the-target-path-contains-emoji-c
After trying different encoding and decoding methods, it was impossible to fix this issue in PowerShell.
Using FFI, which allows interaction with OS APIs (win32 in this case), turned out to be the solution.
The advantage is that it is 10x faster at creating shortcuts than using PowerShell on Windows!
Current Method -> PowerShell (105 seconds) [473 shortcuts] image
New Method -> FFI (12 seconds) [473 shortcuts] image
The code doesn't discard the use of PowerShell, if FFI fails to create the shortcut on Windows, it falls back to the old PowerShell method.
This fixes: #389 It also fixes: #276 (because on Windows shortcuts are created with absolute path)

I write you here because I don't see any other way to contact you from your forked repository (there is no discussion section enabled). I

I have an error during Copying photos but I cannot debug it more. Could you please try to point me what is happening with this log messages?

2025-03-19 05:55:14 [INFO ] - Finding albums (this may take some time, dont worry :) ... 2025-03-19 05:58:05 [INFO ] - 2025-03-19 05:58:05 [INFO ] - 2025-03-19 05:58:05 [INFO ] - Copying photos to output folder : ........................................ 0/13049 2025-03-19 05:58:05 [ERROR ] - Unhandled exception: 2025-03-19 05:58:05 [ERROR ] - type 'String' is not a subtype of type 'num' 2025-03-19 05:58:05 [ERROR ] - #0 main (file:///home/runner/work/GooglePhotosTakeoutHelper/GooglePhotosTakeoutHelper/bin/gpth.dart:423) 2025-03-19 05:58:05 [ERROR ] -

Thanks for the report! The fork now has an issue section. Could you post it there so we can discuss it? This issue is not related to this PR (it's about the date structure option #299)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emoji's in albumn names Shortcuts created with wrong path.

3 participants