Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

larchesdanrew posted:

The solution is probably something I should know, but I've got a problem that causing me a lot of grief.

We have a server that holds all of the commercials the station plays. The commercials are all located in a single folder and the filenames are [five digit number].mpg.

It has never been cleaned out and there are over 16,000 files in there. I have been tasked with clearing it out. All I have is a list of five digit numbers to keep.

Basically, I have a folder of 16,000 video files and I have to delete everything that isn't on a list I have.

I've been on this all morning and have gotten through a few thousand of them. My eyes are crossing at this point and I keep accidentally deleting the wrong files.

Can someone please help me automate this atrocious task? Is there a way I could use a batch file or powershell to delete all the files in a folder except the ones contained in a .txt file?

If it's a filesystem that supports hard links, create a new directory, make hard links of all of the files you need to keep in that directory, then rename that new directory to the old directory. Trash the old directory.

I guess it also depends on how many files are on your list.

Adbot
ADBOT LOVES YOU

DigitalRaven
Oct 9, 2012




The Fool posted:

Hence the part of the sentence after the comma.

I was agreeing with you. And being :smug: that we've had that working for a while.

A Frosty Witch
Apr 21, 2005

I was just looking at it and I suddenly got this urge to get inside. No, not just an urge - more than that. It was my destiny to be here; in the box.

Sickening posted:

Ran into this before as well. Powershell my friend.

gci *.dxf -exclude file1.dxf,file2.dxf | remove-item

Obviosly .dxf would be .mpg but there rest is pretty simple.

gci *.mpg -exclude 12345.mpg,54321.mpg | remove-item

(for the love test it, because deleting won't send it to the recycle bin)

hooooly poo poo that was easy. How do I send you beer?

Vicas
Dec 9, 2009

Sweet tricks, mom.
Batch scripting is fun when soberly done

myron cope
Apr 21, 2009

We have (what is probably) a dumb problem. Some users are having problems opening attachments in email. They don't even see that the message has an attachment. However, this only happens when it's a forwarded message. If I get an email with an attachment and forward it to them, no dice. If I get the same email, save the attachment, then send a new message to the intended recipient, they can see the attachment.

One of our sysadmins who only looks briefly at problems and declares a solution decided it was logging in public v private in owa (I'm pretty sure it's only happening in owa) was the problem and that logging in private (checking the "private computer" radio button) would fix it. It did not. Now they don't care to look into the issue any further.

Sickening
Jul 16, 2007

Black summer was the best summer.

larchesdanrew posted:

hooooly poo poo that was easy. How do I send you beer?

Let the powershell flow through you.

I will have to pass on the beer but I appreciate the offer. Its pretty incredible how much manual work can be skipped by some simple powershell. I have an entire dept right now that could be replaced by a few powershell scripts.

Get the powershell in a month of lunches. It really is an easy read.

The Fool
Oct 16, 2003


myron cope posted:

We have (what is probably) a dumb problem. Some users are having problems opening attachments in email. They don't even see that the message has an attachment. However, this only happens when it's a forwarded message. If I get an email with an attachment and forward it to them, no dice. If I get the same email, save the attachment, then send a new message to the intended recipient, they can see the attachment.

One of our sysadmins who only looks briefly at problems and declares a solution decided it was logging in public v private in owa (I'm pretty sure it's only happening in owa) was the problem and that logging in private (checking the "private computer" radio button) would fix it. It did not. Now they don't care to look into the issue any further.

Not 100 percent certain, but that sounds like a browser issue to me.

EuphrosyneD
Jan 25, 2004

Sickening posted:

Ran into this before as well. Powershell my friend.

gci *.dxf -exclude file1.dxf,file2.dxf | remove-item

Obviosly .dxf would be .mpg but there rest is pretty simple.

gci *.mpg -exclude 12345.mpg,54321.mpg | remove-item

(for the love test it, because deleting won't send it to the recycle bin)

In PowerShell, the -WhatIf parameter will always simulate what would actually happen. Especially nice when testing actions that can't be reversed! For extra fun, use -WhatIf and -Verbose at the same time so it'll tell you what it's doing.

Proud Christian Mom
Dec 20, 2006
READING COMPREHENSION IS HARD
Powershell is Excel for admin work

Sickening
Jul 16, 2007

Black summer was the best summer.

EuphrosyneD posted:

In PowerShell, the -WhatIf parameter will always simulate what would actually happen. Especially nice when testing actions that can't be reversed! For extra fun, use -WhatIf and -Verbose at the same time so it'll tell you what it's doing.

Duh, you are 100% right. I always forget the -whatif parameter. :derp:

Methylethylaldehyde
Oct 23, 2004

BAKA BAKA

Sickening posted:

Duh, you are 100% right. I always forget the -whatif parameter. :derp:

That really is the best parameter.

A Frosty Witch
Apr 21, 2005

I was just looking at it and I suddenly got this urge to get inside. No, not just an urge - more than that. It was my destiny to be here; in the box.

Sickening posted:

I will have to pass on the beer but I appreciate the offer.

I'll keep the beer for myself then because apparently I'm going to need it.

In the time I was given the list of files to the time the script ran, which was about 4 hours, two departments added about 50 commercials without telling me. Guess what files weren't on the list? Guess what the script did to them?

Now I'm getting poo poo all over by management for deleting their files, never mind the fact that these people apparently couldn't manage hold on to a backup copy of these files for a few loving hours. They stuck them in the folder I was working in and then deleted them off their computers.

Seriously, I cut the time required by, like, 80% by using that script. How badly hosed were they gonna be when it took me two days to do it manually and they lost two days worth of poo poo versus just a few hours?

sfwarlock
Aug 11, 2007

Dr. Arbitrary posted:

Just out of curiosity, what's your opinion on the way to resolve a virus infection?

I have a user who got a browser hijacker. Nothing to be ashamed of, something similar happened to me a year back on my home computer.

Do you just clean up the computer with malwarebytes or would it be best to just consider the computer compromised and get a new one?

Backup, format, reinstall, doo dah, doo dah.
Backup, format, reinstall, virus goes away!

Sickening
Jul 16, 2007

Black summer was the best summer.

larchesdanrew posted:

I'll keep the beer for myself then because apparently I'm going to need it.

In the time I was given the list of files to the time the script ran, which was about 4 hours, two departments added about 50 commercials without telling me. Guess what files weren't on the list? Guess what the script did to them?

Now I'm getting poo poo all over by management for deleting their files, never mind the fact that these people apparently couldn't manage hold on to a backup copy of these files for a few loving hours. They stuck them in the folder I was working in and then deleted them off their computers.

Seriously, I cut the time required by, like, 80% by using that script. How badly hosed were they gonna be when it took me two days to do it manually and they lost two days worth of poo poo versus just a few hours?

Ugh, that sucks dude. :smith:

When I am about to do a purge of any type I make it a point to do a broadcast email to let everyone know that data is going to be nuked. I prefer to do purges during the evening hours when people shouldn't be in directories.

A Frosty Witch
Apr 21, 2005

I was just looking at it and I suddenly got this urge to get inside. No, not just an urge - more than that. It was my destiny to be here; in the box.

Sickening posted:

Ugh, that sucks dude. :smith:

When I am about to do a purge of any type I make it a point to do a broadcast email to let everyone know that data is going to be nuked. I prefer to do purges during the evening hours when people shouldn't be in directories.

Oh well, I was just following orders. Good news is that now that I've got this :krad: script ready to go for next time, I've got the process down on taking the list of cart numbers and formatting it for use on the script, so the entire process should only take a few minutes in the future.

This is the second time PS has saved my balls, so I'm definitely gonna check out that read you mentioned.


gently caress this poo poo.

Seriously, my supervisor keeps giving me these insanely tedious tasks because he's a smug rear end in a top hat and he takes joy in thinking I'm spending all day slogging through it, when all I end up doing is automating it and doing real work.

A Frosty Witch fucked around with this message at 21:12 on Mar 4, 2015

afflictionwisp
Aug 26, 2003
The on-site contractor did what, now?

afflictionwisp fucked around with this message at 21:12 on Mar 4, 2015

The Fool
Oct 16, 2003



He was just protesting the oppression of video cards by those pciex retainer clips.

Alighieri
Dec 10, 2005


:dukedog:


Don't the connectors curl over the plastic to help hold the plastic in? That is pretty impressive.

22 Eargesplitten
Oct 10, 2010



I'm phone posting, so I can't see all that well. Is that a PCI express slot pulled off the motherboard?

GreenNight
Feb 19, 2006
Turning the light on the darkest places, you and I know we got to face this now. We got to face this now.

22 Eargesplitten posted:

I'm phone posting, so I can't see all that well. Is that a PCI express slot pulled off the motherboard?

Yup. Someone didn't know about the tab that holds a graphics card in the slot.

Rhymenoserous
May 23, 2008
What tab? Half of the time those brittle pieces of poo poo snap off.

Japanese Dating Sim
Nov 12, 2003

hehe
Lipstick Apathy

GreenNight posted:

Yup. Someone didn't know about the tab that holds a graphics card in the slot.

I almost did that a couple of weeks ago to a SATA port, because the cable had some stupid clasp on it that had to be depressed to remove it from the port. Is this actually necessary or wanted in any situation?

That said, I'm not a complete idiot, so I noticed something was wrong and checked on it before increasing brute force.

Like this -

Sickening
Jul 16, 2007

Black summer was the best summer.

Rhymenoserous posted:

What tab? Half of the time those brittle pieces of poo poo snap off.

Honestly that clip is just bad design. Much like the twist-on for vga and dvi cables. All they ever seem to be good at is causing damage when an accident happens.

GreenNight
Feb 19, 2006
Turning the light on the darkest places, you and I know we got to face this now. We got to face this now.

Agreed. My gaming rig is a mITX motherboard in a tiny case. It's a huge PITA to remove the graphics card due to the lack of space to move the clasp.

Rhymenoserous
May 23, 2008

GreenNight posted:

Agreed. My gaming rig is a mITX motherboard in a tiny case. It's a huge PITA to remove the graphics card due to the lack of space to move the clasp.

I just snap the loving things off. I screwed the video card in it's not going anywhere unless I ship the loving thing, at which point I'd likely remove the vid card for transport anyways.

notwithoutmyanus
Mar 17, 2009

Rhymenoserous posted:

What tab? Half of the time those brittle pieces of poo poo snap off.

Which should make it nigh impossible to to strip the connection off the mobo.

:yotj: that possible shitshow I wasn't chosen for had the person they actually did offer to never show up to work. Total MIA. They stalked the dumbass who had a public Facebook profile with verifiable information and apparently he has lots of time where people ask him where he is and he's missing from a Facebook perspective . Also found out I aced their helpdesk/ccna tests, which is a nice confirmation of my knowledge/skillset.

Was told I'll have an offer within the week. This is great timing, current job PA is this week and 100% politics /full of poo poo. AKA: you met 100% of your goals but we're putting down "needs improvement". So I can use the offer as leverage and/ or push the offer for a better deal.

Sickening
Jul 16, 2007

Black summer was the best summer.

notwithoutmyanus posted:

Which should make it nigh impossible to to strip the connection off the mobo.

:yotj: that possible shitshow I wasn't chosen for had the person they actually did offer to never show up to work. Total MIA. They stalked the dumbass who had a public Facebook profile with verifiable information and apparently he has lots of time where people ask him where he is and he's missing from a Facebook perspective . Also found out I aced their helpdesk/ccna tests, which is a nice confirmation of my knowledge/skillset.

Was told I'll have an offer within the week. This is great timing, current job PA is this week and 100% politics /full of poo poo. AKA: you met 100% of your goals but we're putting down "needs improvement". So I can use the offer as leverage and/ or push the offer for a better deal.

In all honesty you might have some more wiggle room when it comes to your offer if you want to push it a little. They have already wasted a lot of time on their first candidate and just getting this task over with is probably first on the list. I personally would push to get a little higher offer especially when they have admitted you were second fiddle.

BOOTY-ADE
Aug 30, 2006

BIG KOOL TELLIN' Y'ALL TO KEEP IT TIGHT

Inspector_666 posted:

I'm worried the Helpdesk agent had a stroke.

Aww, gibberish news lady got a new job :3:

https://www.youtube.com/watch?v=YxupxBKatX0

Dr. Arbitrary posted:

Just out of curiosity, what's your opinion on the way to resolve a virus infection?

I have a user who got a browser hijacker. Nothing to be ashamed of, something similar happened to me a year back on my home computer.

Do you just clean up the computer with malwarebytes or would it be best to just consider the computer compromised and get a new one?

Depending on how bad it is, I usually run Malwarebytes, ADWCleaner, and Norton Power Eraser. I started running into clients that were getting those drive-by browser toolbars/hijackers that won't show in Add/Remove Programs, but embed in the hidden AppData folder in their profile. Worst case, export your bookmarks, remove the browser, boot to safe mode, delete all the hidden folders in C:\Users\<name>\AppData that were created by the browser, then reboot, reinstall browser and import your bookmarks. I've done this stuff WAY too many times to the point of nearly memorizing the paths to those goddamn hidden AppData folders :argh:

If all else fails (or it'll take more than 30 minutes tops to fix), get a list of all applications/licenses, then reimage from scratch.

BOOTY-ADE fucked around with this message at 22:55 on Mar 4, 2015

Wizard of the Deep
Sep 25, 2005

Another productive workday

larchesdanrew posted:

I'll keep the beer for myself then because apparently I'm going to need it.

In the time I was given the list of files to the time the script ran, which was about 4 hours, two departments added about 50 commercials without telling me. Guess what files weren't on the list? Guess what the script did to them?

Now I'm getting poo poo all over by management for deleting their files, never mind the fact that these people apparently couldn't manage hold on to a backup copy of these files for a few loving hours. They stuck them in the folder I was working in and then deleted them off their computers.

Seriously, I cut the time required by, like, 80% by using that script. How badly hosed were they gonna be when it took me two days to do it manually and they lost two days worth of poo poo versus just a few hours?

Hopefully you've figured it out from this instance, but, unless space is at a premium, move the files somewhere else and sit on them for a while. You could do something like the following:

get-childitem -Path "D:\Commercials" | where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} | move-item -destination "D:\OldCommercials"

All that does is move items that haven't been written to in the last month(ish) and moves them to your designated archive folder.

A Frosty Witch
Apr 21, 2005

I was just looking at it and I suddenly got this urge to get inside. No, not just an urge - more than that. It was my destiny to be here; in the box.

Wizard of the Deep posted:

Hopefully you've figured it out from this instance, but, unless space is at a premium, move the files somewhere else and sit on them for a while. You could do something like the following:

get-childitem -Path "D:\Commercials" | where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} | move-item -destination "D:\OldCommercials"

All that does is move items that haven't been written to in the last month(ish) and moves them to your designated archive folder.

The problem with that is that the files are labelled by cart number (just an identification number) and are associated with an offsite database where the cart numbers are associated with metadata like what the commercial is, who owns it, and, most importantly, the expiration date. We have files in there that are several years old, but the clients still want those commercials run. So, while the file may not have been modified since 2012, the expiration date keeps getting pushed out as the client sees fit.

The only option is to wait until the folder is so full of files that the ingestor starts to crap out from having to keep track of them all, then wait for it to become such a burden on the master control operator that they bitch to the GM, then the GM fusses at my supervisor who finds the lowest person on the totem pole to get a list from each department containing all expired spots and then spends three or four days cleaning them out.

No clue why no one thought to just script the cleaning process, though.

Wizard of the Deep
Sep 25, 2005

Another productive workday

larchesdanrew posted:

The problem with that is that the files are labelled by cart number (just an identification number) and are associated with an offsite database where the cart numbers are associated with metadata like what the commercial is, who owns it, and, most importantly, the expiration date. We have files in there that are several years old, but the clients still want those commercials run. So, while the file may not have been modified since 2012, the expiration date keeps getting pushed out as the client sees fit.

The only option is to wait until the folder is so full of files that the ingestor starts to crap out from having to keep track of them all, then wait for it to become such a burden on the master control operator that they bitch to the GM, then the GM fusses at my supervisor who finds the lowest person on the totem pole to get a list from each department containing all expired spots and then spends three or four days cleaning them out.

No clue why no one thought to just script the cleaning process, though.

Ugh, that's a marvelously horrible system. In that case, as long as you can get a text file, you could use something like

$Expired = get-content \\server\share\ListOfFiles.csv

move-item -path "D:\Commercials\$Expired" -destination "D:\OldCommercials"

If you can't get a text file, well :suicide:

nexxai
Jul 17, 2002

quack quack bjork
Fun Shoe

JohnnyCanuck posted:

Hahaha, I sent this to Organization@ this week:

code:
Hi everybody, a quick reminder:

     • [email]support@OURCOMPANY.com[/email] is used by [i][b]our clients[/b][/i] to create and reply to 
       external tickets/Incidents. This automatically creates or updates tickets in the 
       ticketing system

     • [email]infrastructure@OURCOMPANY.com[/email] also automatically creates or updates tickets in the 
       ticketing system. It should be used if you have an issue with or suggestion for our 
       internal support structure, for example:
          o you need something installed on your laptop
          o you’re getting an error message
          o you want a new feature added to an internal product
          o etc.

     • [email]technical@OURCOMPANY.com[/email] is set up for internal email distribution (it includes the 
       services, support, and development teams). It is the only email address out of these 
       that does not automatically create a ticket, and should therefore be used for general 
       communication.

Thank you for your attention to this matter.
How does it feel to know that you spent 15+ minutes on an email that will in all likelihood see a forward of this message to "support@OURCOMPANY.com" wondering why they're receiving spam.

22 Eargesplitten
Oct 10, 2010



Sickening posted:

Honestly that clip is just bad design. Much like the twist-on for vga and dvi cables. All they ever seem to be good at is causing damage when an accident happens.

Tell me about it. The fans on pretty much every PCI-E card I've used have gotten in the way of the clip. And VGA cables always seem to be put on parallel to the main body of the monitor so you can barely get your fingers on there. And then every rear end in a top hat torques them down with a screwdriver so you have to tear the end up even more with a screwdriver to get it out.

Hands-on pleb IT problems.

Collateral Damage
Jun 13, 2009

All D-sub connectors need to go away. Forever.

A Frosty Witch
Apr 21, 2005

I was just looking at it and I suddenly got this urge to get inside. No, not just an urge - more than that. It was my destiny to be here; in the box.

Wizard of the Deep posted:

Ugh, that's a marvelously horrible system. In that case, as long as you can get a text file, you could use something like

$Expired = get-content \\server\share\ListOfFiles.csv

move-item -path "D:\Commercials\$Expired" -destination "D:\OldCommercials"

If you can't get a text file, well :suicide:

Believe me, I hate it. I'm not allowed access to the system the departments use to input the metadata, which is actually RDP connections through an always-on VPN to the metadata company's system. The commercials all go to the same directory, but each department has a different system they use to input the metadata and they can't access files from other departments.

It's a giant, marvelous piece of poo poo system and I want it gone so so so badly.

ilkhan
Oct 7, 2004

You'll be sorry you made fun of me when Daddy Donald jails all my posting enemies!

Rhymenoserous posted:

What tab? Half of the time those brittle pieces of poo poo snap off.
I wish they all would.
With a big gpu HS/F its nearly impossible to release them.

Sickening
Jul 16, 2007

Black summer was the best summer.
Thats why I only buy HDMI monitors for my personal use these days.

22 Eargesplitten
Oct 10, 2010



I'm pretty sure my monitor has an integrated cable. Or maybe that's the power cable, and I'm misremembering.

My monitor got dumpster dived 10 years ago, and I'm still using it.

CuddleChunks
Sep 18, 2004

larchesdanrew posted:

In the time I was given the list of files to the time the script ran, which was about 4 hours, two departments added about 50 commercials without telling me. Guess what files weren't on the list? Guess what the script did to them?

When new commercials get added they have a cart number associated but is their file creation date for today or is it some time in the past when the cart was originally recorded?

I'm wondering if a check that excludes anything created today wouldn't be helpful in your ever-evolving powershell script. Skip the new stuff, purge the old by shuffling it to another folder (in case something goes wrong) and log the results.

Then autogenerate an ASCII goatse and email that to your boss.

Scripting is the best.

Adbot
ADBOT LOVES YOU

Dunno-Lars
Apr 7, 2011
:norway:

:iiam:



larchesdanrew posted:

I'll keep the beer for myself then because apparently I'm going to need it.

In the time I was given the list of files to the time the script ran, which was about 4 hours, two departments added about 50 commercials without telling me. Guess what files weren't on the list? Guess what the script did to them?

Now I'm getting poo poo all over by management for deleting their files, never mind the fact that these people apparently couldn't manage hold on to a backup copy of these files for a few loving hours. They stuck them in the folder I was working in and then deleted them off their computers.

Seriously, I cut the time required by, like, 80% by using that script. How badly hosed were they gonna be when it took me two days to do it manually and they lost two days worth of poo poo versus just a few hours?


Did you ever get a list of the new poo poo they put in? Were you about to get it? Because if not, you would still have deleted those files manually, since noone told you about it. The blame really is not on you here, but the morons that added those files.

  • Locked thread