Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wacheee
Copy link

@Wacheee Wacheee commented Mar 5, 2025

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
@Jazza-231
Copy link

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

@jaimetur
Copy link

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
Copy link
Author

Wacheee commented Mar 19, 2025

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