0

We have customized an application (Polarion ALM) by adding some CSS-code to stylesheets from the application. However, those stylesheets are located in a server-path, which is affected from updates. For this issue we have started creating a very simple Batch-file to copy lines of code to the stylesheets.

Here an example:

echo .anyclass {color:red;} >> \\serveradress\folder_3.18.0\Chrome.css

The script itself works fine - however the problem is that with every update of the application the foldername "folder_3.18.0" changes, in which the stylesheet is located, for example to "folder_3.18.1" or "folder_3.19.0" (At least only the number changes).

Is there any trick to handle in the script this dynamic number behind the "folder_"? Or any workaround? Unfortunately I have to stick to the "not-update-safe" path to locate the stylesheet.

There is a similar question in this forum, but I don't understand how to transfer it to my Use-Case - as I am totally new to Batch-Files: create batch file to copy folder contents with dynamic name

1 Answer 1

1
FOR /D %%A IN ("\\servername\plugins\com.softwarename.alm.ui_") DO SET "folder=%%A"
echo %folder%

will return you the last matching folder. So the your example changes to:

echo .anyclass {color:red;} >> "%folder%\Chrome.css"
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much Stephan. One little issue left: Now my "folder" has a name format like: "\\servername\plugins\com.softwarename.alm.ui_*". Does powershell recognize that "."? Do I have to change all "folder" in the code with "com.softwarename.alm.ui"? Excuse please my rookie questions :)
This is batch, not powershell. A dot (.) is a valid character for a folder- or file-name. The for /D looks for matching folders, so if you look for \\servername\plugins\com.softwarename.alm.ui_something, yes, you have to use \\servername\plugins\com.softwarename.alm.ui_* (the known part plus a wildcard for the unknown part)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.