4

There are instructions on how to use a bash script in the SendTo folder (using the instructions in the below link). However, I would like to execute a PowerShell script instead.

Is it possible to use a shell script in the sendto folder

I would like for the shortcut to execute a PowerShell function that I have defined in my PowerShell profile called, Invoke-SendToUPLOAD... where Invoke-SendToUPLOAD accepts the full file path of the sendto file as a parameter by default.

I "almost" have what I want. However, filepaths that have spaces in them are truncated. Could someone tell me how to preserve the filepath even if there's a space in the path. I've tried putting double-quotes around %1 below. However, that doesn't work either.

C:\Windows\System32\cmd.exe /c start /min cmd.exe /c PowerShell.exe -Command "& {param ($I = {%1} ); Invoke-SendToUPLOAD }"

2 Answers 2

1

There was a solution on StackOverflow for this: https://stackoverflow.com/a/15934981/651934

In short, surround the parameter with single quotes. In your case, the following should work:

C:\Windows\System32\cmd.exe /c start /min cmd.exe /c PowerShell.exe -Command "& {param ($I = {'%1'} ); Invoke-SendToUPLOAD }"

The downside is that this doesn't support filenames that contain a single quote. But spaces and other characters work fine.

0

I was trying to find a way to use a Powershell PS1 script to change the case of selected filenames using the SendTo folder.

Using a batch file with the command lines described in previous comments did NOT work for me.

First, I created the following PS1 script:

#filenames-to-lowercase-recursively,ps1

Get-ChildItem -recurse | Where {-Not $.PSIsContainer} | Rename-Item -NewName { $.FullName.ToLowerInvariant() }

Then, I converted the PS1 file to an EXE file and copied the EXE file to the SendTo folder. I used the online converter at Online Powershell to Exe Converter.

The EXE version of the PS1 file worked perfectly for selecting desired files and running the EXE from the Send to menu. I could even select multiple files without problems.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .