[Mi...] Posted December 20, 2024 Share Posted December 20, 2024 (edited) I want to make a parametric program, that I can edit entirely outside of the program... Is there a function that simply will give me all the file names in a directory? Basically, can I read these 3 files and get them in a list? or is this going to be something that needs done with getParameterNamed() and a loop? Edited December 20, 2024 Link to comment Share on other sites More sharing options...
[Ch...] Posted December 20, 2024 Share Posted December 20, 2024 (edited) Im sure these is, I will search when I have some time.. Question : if you're making the parametric program, do you just want to check to make sure these 3 files exist ? fileExists() Is it important for the program to know if there are more files or you just want to check to make sure ? Edited December 20, 2024 Link to comment Share on other sites More sharing options...
[Ch...] Posted December 20, 2024 Share Posted December 20, 2024 Seems there is a way with a batch file or hidden PCM ... https://forums.zeiss.com/messtechnik/community/viewtopic.php?p=58354&hilit=run+bat+file#p58354 Link to comment Share on other sites More sharing options...
[DW...] Posted December 27, 2024 Share Posted December 27, 2024 I am not exactly sure of your needs, but this is a Powershell script that will read the contents of each text file in the folder and then append it into a single text file. Is that what you are trying to do? # Define the directory containing the text files $sourceDirectory = "C:\Path\To\Your\TextFiles" # Define the output file where all contents will be combined $outputFile = "C:\Path\To\Your\CombinedOutput.txt" # Check if the output file already exists and remove it to avoid appending to old data if (Test-Path $outputFile) { Remove-Item $outputFile } # Get all .txt files in the specified directory $textFiles = Get-ChildItem -Path $sourceDirectory -Filter "*.txt" # Loop through each text file and append its content to the output file foreach ($file in $textFiles) { # Read the content of the text file $content = Get-Content -Path $file.FullName # Append the content to the output file Add-Content -Path $outputFile -Value $content # Optionally, add a newline for separation between files Add-Content -Path $outputFile -Value "`n" } Write-Host "All text file contents have been combined into $outputFile" Link to comment Share on other sites More sharing options...
[Mi...] Posted January 6 Author Share Posted January 6 Please sign in to view this quote. Yes! Although Powershell is blocked at my company.... Love blanket IT security policies... anyway, I did get a fully PCM version working. Some of my own discovery, some from other forum posts over there years. In short, it looks inside the current program directory and inside a folder called PCM, then reads the names of all the .txt files in there, and automatically puts them into an inquireList()... From there you can do anything you like based on the selection. Now, I can make a completely parametric program, and just teach the others how to make the parameter file - by copying one of the existing ones and updating the name and parameter values - And that new one will automatically show up on the list. There's about 40 masters, and they will have to be redone on a schedule so this effort is definitely worth it if I can make 1-2 work then pass off the project. directoryPath = getActualInspectionDir() + "\PCM" directoryContent = directoryPath.asFilename.directoryContentsAsFilenames //Traps in a loop, forces selection or cancel repeat //Dynamic InquireList() Start GaugeIDList = "" GaugeIDList = "inquireList(" + qm() + "Choose Machine Number (Last Entered: )" + qm() loopBreak=false for i = 1 to directoryContent.size GaugeIDList = GaugeIDList +","+ qm() + subStr(getParameterNamed(directoryContent,i).asString,(2+len(directoryPath)),(inStr(getParameterNamed(directoryContent,i).asString,".")-1)) +qm() next i GaugeIDList = GaugeIDList + ")" GaugeIDSelection = compute(GaugeIDList) //DynamicInquireList() End if GaugeIDSelection == "" then loopBreak = confirm("Cancel?") else loopBreak = true endif until loopBreak Link to comment Share on other sites More sharing options...
[DW...] Posted January 6 Share Posted January 6 (edited) Add this at the very beginning of your Powershell script. PowerShell -ExecutionPolicy Bypass -File "C:\Path\To\YourScript.ps1" It changes the Execution Policy for that script only to run regardless of your IT settings. Edited January 6 Link to comment Share on other sites More sharing options...
[Mi...] Posted January 6 Author Share Posted January 6 They block it via a third party app called Sophos... it's brutal. Only way around is to kill Sophos, but then you start getting unhappy messages from corporate IT.. Please sign in to view this quote. Link to comment Share on other sites More sharing options...
[DW...] Posted January 6 Share Posted January 6 Have you tried opening the Powershell ISE by right clicking and selecting "Run as administrator"? I have Sophos too but am able to get around it. Link to comment Share on other sites More sharing options...
[Mi...] Posted January 6 Author Share Posted January 6 I can do this on my own PC that's not an issue, as I am an Administrator on it. But it can't be done on the CMM PCs where this code will need to run. They are so ridiculously locked down there's no practical way around it. I keep getting promised that some of the policies are intended to relax once they have all the big security stuff done. We'll see what happens. Link to comment Share on other sites More sharing options...
[An...] Posted January 7 Share Posted January 7 Please sign in to view this quote. Very nice work building that dynamic list and using compute! Very nice! Link to comment Share on other sites More sharing options...
[Gu...] Posted January 12 Share Posted January 12 // Maybe also usefull... Path ="C:\Temp\" Filter = "*.pdf" Dialog ="Please select" Mode = 0 // 0 or emty: Path with Filename // 1: filename // 2: path // 3: Filename as an object MyFile = selectFileDialog(Path,Filter,Dialog,Mode) display(MyFile) Link to comment Share on other sites More sharing options...
[Mi...] Posted January 13 Author Share Posted January 13 Please sign in to view this quote. This was essentially my backup plan, and honestly it would have worked just fine. selectFileDialog() technically lets you select any file from the given directory. And it wouldn't have any issues with file name formatting and such that I may run into with my solution. It just looks a bit fancier for it to stay in windows like this now. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in