Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting the folder name #397

Answered by tfeldmann
colindavidfoster asked this question in Q&A
Discussion options

How can I get the current folder from the path?

For example if {path} is \\microserver\Downloads\complete\Test\advert.mpg.zero
I get
\\microserver\Downloads\/complete
Test/advert.mpg.zero
- (echo) Path is \\microserver\Downloads\complete\Test\advert.mpg.zero
- (echo) Relative Path is Test\advert.mpg.zero
- (echo) Name is advert.mpg

How can I get \\microserver\Downloads\complete\Test into, say, {folder} so that I can use something like

  • shell: 'touch "{folder}\{name}"'

Here's my rule.

rules:
 - name: Truncate To Zero
 locations:
 - path: \\\\microserver\\Downloads\\complete
 subfolders: true
 filters:
 - name:
 - extension: ["zero"]
 actions:
 - echo: Path is {path}
 - echo: Relative Path is {relative_path}
 - echo: Name is {name}
 #- shell: 'touch "{folder}\\{name}"'
 - delete:
 tags:
 - debug
You must be logged in to vote

I think you‘re searching for {path.parent}?

Replies: 1 comment 2 replies

Comment options

I think you‘re searching for {path.parent}?

You must be logged in to vote
2 replies
Comment options

Perfect, but not in the docs :-(

Comment options

We absolutely need better docs for this 👍
Right now there is only a link to pathlib.Path and the user is expected to know the rest.

Answer selected by colindavidfoster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /