Delete contents of a folder every night


Recommended Posts

there are several ways.

the way I would do it is set a task in task scheduler and either set the delete command right in the task or point the task to a batch file

  • Like 2

Off the top of my head, I'd probably create a batch script and put it into the task scheduler to run each night, maybe at 0300 or something.

I think the command would be:

cd C:\Users\James\AppData\Local\Plex Media Server\Cache\
rmdir /s /q PhotoTranscoder

 

On 08/02/2024 at 10:03, Nick H. said:

Off the top of my head, I'd probably create a batch script and put it into the task scheduler to run each night, maybe at 0300 or something.

I think the command would be:

cd C:\Users\James\AppData\Local\Plex Media Server\Cache\
rmdir /s /q PhotoTranscoder

 

technically don't even need the cd command; can just be a one line command. also would need "" around the directory path due to the spaces in the Plex Media Server folder.

rmdir /s /q "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"

 

On 08/02/2024 at 08:07, Brandon H said:

technically don't even need the cd command; can just be a one line command. also would need "" around the directory path due to the spaces in the Plex Media Server folder.

rmdir /s /q "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"

 

Thank you, what would be the command to just delete the contents of the folder instead of the folder itself ?

On 08/02/2024 at 11:09, jamester64 said:

Thank you, what would be the command to just delete the contents of the folder instead of the folder itself ?

I think a standard del command with a * wildcard should work

del /S /Q /F "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*"

 

On 08/02/2024 at 12:18, Brandon H said:

I think a standard del command with a * wildcard should work

del /S /Q /F "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*"

 

Please note, these "del" and "rmdir" commands will not work with powershell and will only work in the context of cmd.exe

 

If you are going to create a scheduled task for this and wish to use these CMD commands, you will need to create the "Action" as follows:

In the "Program/script" portion of adding a new "Start a program" action, you would put cmd.exe with the arguments /C "del /S /Q /F 'C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*"'

 

A functional scheduled task would look like this:

image.png.cca282ba8e80f86fac5d05c704697108.png

On 08/02/2024 at 09:18, Brandon H said:

I think a standard del command with a * wildcard should work

del /S /Q /F "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*"

 

That deleted the contents of the folders inside the directory but left the folders

Looking to delete the entire contents of this folder  C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder

On 08/02/2024 at 12:28, jamester64 said:

That deleted the contents of the folders inside the directory but left the folders

Looking to delete the entire contents of this folder  C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder

You can do this with Powershell and the "Remove-Item" command: 

remove-item c:\utils\test\* -recurse -force

If you wanted to bake it into a scheduled task, you can run powershell.exe with the -command argument like follows:

powershell.exe -command "remove-item c:\utils\test\* -recurse -force"

 

  • Like 2
  • Love 1
On 08/02/2024 at 11:28, jamester64 said:

That deleted the contents of the folders inside the directory but left the folders

Looking to delete the entire contents of this folder  C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder

yeah, bad limitation of the two commands. alternate option would be go back to previous command and just have a 2nd command to recreate the folder after I think

rmdir /s /q "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"
mkdir "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"

 

On 08/02/2024 at 11:32, satukoro said:

You can do this with Powershell and the "Remove-Item" command: 

remove-item c:\utils\test\* -recurse -force

 

also a good option. I'm still familiarizing myself with the PowerShell version of commands like that so didn't think of it.

On 08/02/2024 at 12:33, Brandon H said:

yeah, bad limitation of the two commands. alternate option would be go back to previous command and just have a 2nd command to recreate the folder after I think

rmdir /s /q "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"
mkdir "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"

also a good option. I'm still familiarizing myself with the PowerShell version of commands like that so didn't think of it.

I nearly posted the same solution of "make the directory after deleting it" but realized I had just done this in a .ps1 script I wrote for something random at my job.

On 08/02/2024 at 09:32, satukoro said:

You can do this with Powershell and the "Remove-Item" command: 

remove-item c:\utils\test\* -recurse -force

If you wanted to bake it into a scheduled task, you can run powershell.exe with the -command argument like follows:

powershell.exe -command "remove-item c:\utils\test\* -recurse -force"

 

Running this in PS doesn't seem to do anything,

remove-item C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\* -recurse -force 

On 08/02/2024 at 13:02, jamester64 said:

Running this in PS doesn't seem to do anything,

remove-item C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\* -recurse -force 

don't forget your quotes around the directory path due to the spaces

remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

and this would be run from powershell.exe instead of cmd.exe | or as a .ps1 file instead of .cmd

On 08/02/2024 at 11:08, Brandon H said:

don't forget your quotes around the directory path due to the spaces

remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

and this would be run from powershell.exe instead of cmd.exe | or as a .ps1 file instead of .cmd

Got it :-)

remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

Thank you

  • Like 3
On 08/02/2024 at 11:08, Brandon H said:

don't forget your quotes around the directory path due to the spaces

remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

and this would be run from powershell.exe instead of cmd.exe | or as a .ps1 file instead of .cmd

I'm having trouble running this in task schedule 

this is what I have in scheduler and I see PS quickly open then close but files remain, not sure what I am missing

-command remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

Annotation 2024-02-08 132328.png

On 08/02/2024 at 15:25, jamester64 said:

I'm having trouble running this in task schedule 

this is what I have in scheduler and I see PS quickly open then close but files remain, not sure what I am missing

-command remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

Annotation 2024-02-08 132328.png

if you're setting the 'program' to powershell.exe then you don't need '-command' at the beginning of your argument

On 08/02/2024 at 13:30, Brandon H said:

if you're setting the 'program' to powershell.exe then you don't need '-command' at the beginning of your argument

Program is set to Powershell.exe and added just this to argument and still not working in scheduler,        remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

not sure what I'm doing wrong

Edit- I just found a way to make it work by adding this  -ExecutionPolicy Bypass C:\Users\James\PlexClean.ps1

Edited by jamester64
On 08/02/2024 at 18:30, jamester64 said:

Program is set to Powershell.exe and added just this to argument and still not working in scheduler,        remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force

not sure what I'm doing wrong

Edit- I just found a way to make it work by adding this  -ExecutionPolicy Bypass C:\Users\James\PlexClean.ps1

I apologize for the late reply. If you wanted to avoid including -executionpolicy bypass and/or using a .ps1, the argument field should look like the following:

-command 'remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force'
# or alternatively this:
-command "remove-item 'C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*' -recurse -force"

The issue with what you had in there before was the missing single quote. By placing the entire command within a set of quotes (either single or double, but not the same ones you use for your folder path), you pass the entire quoted string into powershell.

If you want to continue using your powershell script file (.ps1), the argument field could look like this:

-executionpolicy bypass -file "c:\path\to\script.ps1"

It looks like you figured it out on your own, but I wanted to add this information for clarity.

--

On 08/02/2024 at 16:30, Brandon H said:

if you're setting the 'program' to powershell.exe then you don't need '-command' at the beginning of your argument

In regards to this, I think you only need the -command argument if you are not going to reference a script. I have not tested this however to see if -command is an implied argument for powershell. Another thing to note (according to the following link) is that the -command argument must be the final argument, otherwise the rest of the arguments are run as part of the -command arg. More information can be found here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1

On 09/02/2024 at 08:24, satukoro said:

I apologize for the late reply. If you wanted to avoid including -executionpolicy bypass and/or using a .ps1, the argument field should look like the following:

-command 'remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force'
# or alternatively this:
-command "remove-item 'C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*' -recurse -force"

The issue with what you had in there before was the missing single quote. By placing the entire command within a set of quotes (either single or double, but not the same ones you use for your folder path), you pass the entire quoted string into powershell.

If you want to continue using your powershell script file (.ps1), the argument field could look like this:

-executionpolicy bypass -file "c:\path\to\script.ps1"

It looks like you figured it out on your own, but I wanted to add this information for clarity.

--

In regards to this, I think you only need the -command argument if you are not going to reference a script. I have not tested this however to see if -command is an implied argument for powershell. Another thing to note (according to the following link) is that the -command argument must be the final argument, otherwise the rest of the arguments are run as part of the -command arg. More information can be found here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1

Thank you for the explanation of what i was doing wrong and the fix ;-) 

Did some testing and this line worked 

-command "remove-item 'C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*' -recurse -force"

This line did not 

-command 'remove-item "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder\*" -recurse -force'

 

# Specify directory to clear
$Path = "C:\Users\James\AppData\Local\Plex Media Server\Cache\PhotoTranscoder"

# Remove items
Remove-Item "$Path\*" -Recurse -Force

Save as Clear-PlexCache.ps1

Task scheduler:

Run: powershell.exe
Command arguments: -ExecutionPolicy Bypass -File "Clear-PlexCache.ps1"
Folder to start in: <path to script folder>

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Segra 1.6.2 by Razvan Serea Segra is a free, open-source OBS-powered game recorder offering fast gameplay capture, instant clips, AI highlights, deep game integration, and seamless uploads—perfect for gamers, streamers, and content creators. Lightweight, fast, zero bloat. Segra key features: Automatic Game Recording: Begin capturing gameplay the moment your game launches, with zero manual setup. Instant Clipping: Save important moments instantly using a customizable hotkey—perfect for highlights, montages, or quick shares. Segra AI Highlights: Let Segra automatically detect kills, assists, deaths, and key events to generate polished highlight reels without manual editing. Gameplay Uploads: Upload recordings and clips directly to Segra.tv for fast sharing and cloud access. Deep Game Integration: Enjoy advanced game-data tracking across hundreds of supported titles, enabling smart highlight generation and stat-informed clipping. High-Performance Capture: Record up to 4K at 144 FPS using OBS-powered technology with minimal performance impact, supporting NVENC, AMD VCE, and custom quality controls. Segra Editor: Edit recordings easily with timeline controls, segment management, and event-based navigation to build the perfect clip. Customization Options: Adjust hotkeys, output formats, storage paths, codecs, capture quality, and performance settings for a tailored recording experience. Segra 1.6.2 changelog: UI: Improved the transition from the loading skeleton to the real content card. Security: Added Segra.dll code signing and automatic VirusTotal upload. Settings: Fixed the settings header to highlight Account when scrolled to the top. Recording: Updated OBSKit.NET to 1.4.1. Download: Segra 1.6.2 | 74.5 MB (Open Source) View: Segra Homepage | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Hey Google, these are the Gemini features I want in 2026 by Aditya Tiwari Google Gemini has been around for over three years. The AI chatbot started its journey back in 2023 (as Bard) when ChatGPT was already a talk of the town. However, it quickly attracted criticism after misrepresenting facts about the James Webb Space Telescope. The search giant spent a year fine-tuning Bard before rebranding the chatbot and its underlying generative AI model to Gemini, drawing inspiration from NASA's first human spaceflight program. Note that Bard was initially powered by LaMDA and PaLM 2; Google has since added several new features and integrations to Gemini. That said, there is scope for improvement and a gap for new features. I have been using Gemini for a while now and have realized that the chatbot lacks several features, making it harder for me to research across topics. These are mostly function-over-form updates that can improve the overall experience. Delete individual messages from a conversation Image via DepositPhotos.com One good thing about Gemini is that it can maintain context throughout the conversation. But things might get chaotic when you want to ask a related question, but don't want it to be part of your conversation in the long run. You can't ask that related question in a fresh chat because Gemini will lose the active conversation context of what you're trying to research. If Google allowed you to delete individual question/answer pairs, you could simply ask about a sub-topic and remove it from the conversation to create a smooth flow of important stuff. Offline mode Image via DepositPhotos.com A big pain of using Gemini daily is that everything loads from the cloud. It takes time for your chats to appear, and you can't view your conversation history while offline. To get a better idea, you can open the Gemini app and see how it looks without an internet connection. While Gemini models run in the cloud, it wouldn't hurt if Google could store chats (at least the text part) on the device so we can refer to them when offline. Google can also offer a lightweight version of its AI model to help with basic drafting, summarization, and other tasks. It has the Gemini Nano model, which can perform on-device processing on Google Pixel, Samsung, and some other Android brands, but it's a system feature and not related to the cloud-based Gemini app. Make temporary chats permanent I can't thank Google enough for taking the time and effort to add incognito mode or temporary chat mode to the Gemini app. It lets you have conversations without worrying that the topics will end up in your chat history or used for model training (at least on paper). Google claims that it doesn't use your temporary chats to "personalize your Gemini experience or train Google’s AI models." However, the data is stored "up to 72 hours to respond to you and to process any feedback you choose to provide." That said, I often start researching something in a temporary chat, only to realize the chatbot's answer is good enough to refer to later. Sadly, Gemini doesn't have an option to make such temporary chats permanent. In other words, I won't be able to follow up on it if I close the temporary chat. I'm left with alternatives like copying the answers into notes or another app. My digital life will get a lot better if Gemini gets a button to make temporary chats permanent. Collapse answers for a cleaner view You're heavily invested in your research game and suddenly feel the need to go up in the chat to recall something. This is when the conversation thread starts to feel like an overwhelming, unending wall of questions and answers. What if Google added a way to collapse Q&A pairs in the Gemini chat thread? It would look quite clean and easy to navigate. You'll quickly get an overview of everything you have discussed with the chatbot. Add buttons to jump between messages Suggested mockup of the feature. This reminds me of a small but useful Gemini feature that Google could add to its chatbot: the ability to hop between prompts in a conversation. Just add simple up- and down-arrow buttons, similar to YouTube Shorts, so people can quickly scroll through the messages. A table of contents or Chat Overview It's hard to get a bird's-eye view of everything you have discussed with the chatbot during a lengthy conversation. This is where a table of contents, or Chat Overview, displayed at the top of the screen, possibly in a drop-down button, might come in handy. You'll be able to get an overview of the chat and jump between messages, serving as an alternative to the up/down arrow buttons. Temporary mode for Gemini Live Image: Google You can use Gemini Live to have real-time conversations with the chatbot, which feels like you're talking to someone in the same room. However, a downside is that Gemini Live doesn't work in Temporary Chat mode, so all your conversations end up in the chat history. Google should consider expanding the temporary chat mode to include Gemini Live. Default to a specific chat One thing that feels somewhat annoying to me is that Gemini always opens in a new chat, whether on web or mobile. Sometimes, you want to return to your last chat. Google can take cues from web browsers, which let you choose whether you want to go to a new tab or a specific web page(s). Gemini can also have options to default to a specific chat when reopened. That said, generative AI chatbots have endless possibilities given the vagueness of their work. You can mold them the way you want by attaching different connectors, adding custom instructions, and including source files. It remains to be seen what Google has in store for future updates and whether anything from this wishlist gets the green light. The search giant released a stream of new Gemini updates in recent months, including Gemini 3.5 Flash and Gemini Omni Spark, adding that it now has 13 products with more than a billion users each. What do you want to see in the Gemini app? Tell us in the comments.
    • Thank you for the post. Just a FYI that links to an outside site or promoting specific software is considered spamming here. Asking general questions is fine.
    • I have been thinking about AI detector tools as a software workflow rather than a single "AI score" widget. When someone pastes text or uploads a document, the UI can return a report with a probability-style score, sentence highlights, reliability notes, and limitations. The useful part is that it can point a reviewer toward passages worth reading again. The risky part is that a polished score can look more certain than it really is. For people who build or review web apps, what should happen before the user copies or exports that kind of report? The minimum I would expect is: A clear input boundary for pasted text versus document files. Limits shown near the workflow, including minimum text length and maximum file size. A report label that says the result is a signal, not proof of who wrote the text. Sentence highlights and evidence notes alongside the global score. Reliability notes when the sample is too short or lacks enough sentence variety. False-positive and false-negative caveats that remain visible in copied/exported summaries. I am trying to avoid the pattern where a clean report card becomes the whole product story. For AI detection, "review this evidence in context" seems more honest than "trust this score." Would you keep the warning text visible on every report, or make it collapsible so the main result stays easier to scan? Disclosure: I work on a small AI detector/reporting workflow, but I am intentionally not linking it here. I am asking about software and report design, not promoting a site.
  • Recent Achievements

    • Conversation Starter
      sumytbe earned a badge
      Conversation Starter
    • One Year In
      B4dM1k3 earned a badge
      One Year In
    • One Year In
      DarkWun earned a badge
      One Year In
    • Dedicated
      Almohandis earned a badge
      Dedicated
    • Dedicated
      JuvenileDelinquent earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      507
    2. 2
      +Edouard
      181
    3. 3
      PsYcHoKiLLa
      86
    4. 4
      Michael Scrip
      78
    5. 5
      Steven P.
      76
  • Tell a friend

    Love Neowin? Tell a friend!