NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Legacy (v4.x and earlier) v
« Previous 1 … 46 47 48 49 50 … 433 Next »
Having problems when there is an & in file name

Having problems when there is an & in file name
scJohn
Offline

Senior Member

Posts: 281
Threads: 41
Joined: Jun 2013
#1
2018-08-23, 09:08 PM
I am having problems passing the file:

"D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts"

as a parameter from a batch file to a powershell script. The character & is a command in both cmd and powershell.

Is there something is the config file that will change & to and?

Found <FileNameReplaceSpaceWithPeriod>false</FileNameReplaceSpaceWithPeriod> but that seems to leave the & alone.

Also found <StrippedEPGPrefixes>Movie:~MOVIE:~New:~All New</StrippedEPGPrefixes>. Could I add :& to the list.

I'm already using """ to wrap the file name and I am still having problems.

Thanks
Server:
CPU- Intel I5-8400, Ram -12GB, SSD - 128GB, HDD - 1TB, Turners - Hauppauge WinTV-quadHD, OS - Win 10 Home, Router - TP-Link Archer C7(AC1750).

Clients:
Intel NUC CPU - Intel N3700, RAM - 4GB, SSD - 128GB, OS - Win 10, Wired Ethernet.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,867
Threads: 954
Joined: May 2006
#2
2018-08-23, 10:45 PM
Why not consider improving your script?

Martin
Maverick
Offline

Junior Member

Posts: 31
Threads: 2
Joined: Jul 2018
#3
2018-08-23, 10:47 PM
scJohn Wrote:I am having problems passing the file:

"D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts"

as a parameter from a batch file to a powershell script. The character & is a command in both cmd and powershell.

Is there something is the config file that will change & to and?

Found <FileNameReplaceSpaceWithPeriod>false</FileNameReplaceSpaceWithPeriod> but that seems to leave the & alone.

Also found <StrippedEPGPrefixes>Movie:~MOVIE:~New:~All New</StrippedEPGPrefixes>. Could I add :& to the list.

I'm already using """ to wrap the file name and I am still having problems.

Thanks

Found this that might help and would remove the need to rename the file. This should only be done in PowerShell.

To help address this scenario, we added a new way to “escape” the parsing of command lines. If you use a magic parameter --%, we stop our normal parsing of your command line and switch to something much simpler. We don’t match quotes. We don’t stop at semicolon. We don’t expand PowerShell variables. We do expand environment variables if you use Cmd.exe syntax (e.g. %TEMP%). Other than that, the arguments up to the end of the line (or pipe, if you are piping) are passed as is. Here is an example:

echoargs.exe --% %USERNAME%,this=$something{weird}
Arg 0 is <jason,this=$something{weird}>
scJohn
Offline

Senior Member

Posts: 281
Threads: 41
Joined: Jun 2013
#4
2018-08-24, 09:40 PM (This post was last modified: 2018-08-24, 09:49 PM by scJohn.)
I tried that but could not get to work. Maybe not doing it right. Here is the powershell command:
Code:
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File """"%DIRLOC%Scheduler.ps1"""" """"%ARG1%""""  """"%Run%"""" ' -Verb RunAs}"

This works for all cases except when there is an & in the file name or folder name.

I can get it to work but I have to edit the file name from

"D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts"

to

"D:\Users\Public\Recorded TV\Mike `& Molly\Mike `& Molly.S06E05.Joyces Will Be Done.ts"
Server:
CPU- Intel I5-8400, Ram -12GB, SSD - 128GB, HDD - 1TB, Turners - Hauppauge WinTV-quadHD, OS - Win 10 Home, Router - TP-Link Archer C7(AC1750).

Clients:
Intel NUC CPU - Intel N3700, RAM - 4GB, SSD - 128GB, OS - Win 10, Wired Ethernet.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,867
Threads: 954
Joined: May 2006
#5
2018-08-24, 10:11 PM
If you run a ps1 file directly without creating a shell in PowerShell does it solve the problem?

Martin
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#6
2018-08-25, 01:57 PM
Not sure if I am emulating your scenario, but I created a batch (cmd) script and a powershell script and it seems to pass the filename correctly. Here is the code:

test.cmd
Code:
@Echo off
set fn="D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts"

Echo The test filename: %fn%
Echo.
Echo List current powershell policies...
powershell Get-ExecutionPolicy -list
pause
Echo.
Echo Set the powershell execution policy...
powershell Set-ExecutionPolicy Unrestricted -Scope CurrentUser
powershell Get-ExecutionPolicy -list
pause

Echo Run the test powershell script...
powershell -file test.ps1 %fn%
pause

Echo.
Echo Reset the powershell execution policy...
powershell Set-ExecutionPolicy Undefined -Scope CurrentUser
powershell Get-ExecutionPolicy -list


test.ps1

Code:
write-host "You are in the powershell script"

write-host "The passed argument(s) are:"
write-host $args[0]

write-host "You are leaving the powershell script"

The output:
Code:
C:\temp>test
The test filename: "D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts"

List current powershell policies...

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
LocalMachine       Undefined


Press any key to continue . . .

Set the powershell execution policy...

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    Unrestricted
LocalMachine       Undefined


Press any key to continue . . .
Run the test powershell script...
You are in the powershell script
The passed argument(s) are:
D:\Users\Public\Recorded TV\Mike & Molly\Mike & Molly.S06E05.Joyces Will Be Done.ts
You are leaving the powershell script
Press any key to continue . . .

Reset the powershell execution policy...

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
LocalMachine       Undefined



C:\temp>
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  incorrect frequency in adelaide .ini file spin35 5 2,958 2023-02-01, 05:40 PM
Last Post: sub
  ts file shows length too long? SuttonWillow 2 1,875 2021-03-15, 01:56 PM
Last Post: mvallevand
  Unhandled Exception: file name too long (idiots at pbs made it super long) jobby99 1 1,381 2020-10-29, 09:40 PM
Last Post: mvallevand
  ts file shows length too long SamM 4 2,306 2020-10-06, 02:45 AM
Last Post: Ehrlichia
  EPG displaying small subset of xmltv file. Esteban 9 2,968 2020-07-18, 10:07 PM
Last Post: Esteban
  Max File Size jrockow 2 1,509 2020-04-21, 02:38 PM
Last Post: jrockow
  Skip causes fast-forward to the end of the file madbrain 9 3,785 2020-02-27, 10:24 PM
Last Post: Esch
  Be notified when EPG (xml file) is empty ? nonob 2 1,407 2020-02-14, 05:00 PM
Last Post: nonob
  Recording extra 0-byte .ts file seeker_ktf 6 2,632 2020-01-25, 08:40 PM
Last Post: seeker_ktf
  Pass M3U File from NextPVR to VLC/Other Mark-McG 3 5,519 2019-12-16, 10:26 AM
Last Post: Mark-McG

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode