Wednesday, January 29, 2014

Bulk Update File Time Stamp Based On Name

So there are a ton of bulk file updaters out there, including ones that shift or set timestamps (my favorite being this one from NirSoft). There are even a couple that update based on EXIF data. But what I wasn't able to find was one that updated based on the file name. Okay, I found one but it required Cygwin and I wasn't that ambitious.

I've been doing a lot of data mining using PowerShell recently, so I've really come to appreciate how powerful it is. I'm amazed at what I can do with such a simple scripting language and I know what I'm doing pales in comparison to what "real" developers can do with it. But it's fun for me so I wrote a little script to update the Creation Time and the Modified Time on the files based on the *name* of the file.

About a month ago I moved about a thousand pictures from my phone's internal storage to the SD card to free up some space. Whatever utility I used wasn't smart enough to copy the time stamps to the new file, so suddenly I had a couple of years worth of photos all with the same date. Needless to say this made browsing the gallery on the phone and actually finding something a pain.

So anyway, here's the script. I'm sure it's not that elegant and I know I can condense a lot of this, but I wanted it to be easy to understand and modify as well. If it helps you say thanks in the comments.

(It's hard to colorize this in blogger and keep the formatting good, so sorry about that.  You can download the actual script from here.)


<# This script updates the created timestamp and the last modified timestamp of all of the files in a folder based on the filename being in the following format: YYYYMMDD_HHMMSS.jpg (doesn't have to be jpg) It only matters that the first 15 characters are in that format - anything afterwards is fine. It assumes that you are in the folder you wish to process before you call the script. There's no error checking in this except to check for an empty folder, so don't use this if you don't know what you're doing. I spent about 10 minutes writing and testing this script and it served its purpose for me. It should be very easy to modify for different file name formats. *** MAKE A BACKUP BEFORE YOU RUN THIS *** THE SCRIPT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SCRIPT OR THE USE OR OTHER DEALINGS IN THE SCRIPT. #> $FilesInFolder = Get-ChildItem $NumFiles = $FilesInFolder | Measure-Object if ($NumFiles.Count -eq 0) { Write-Host "No Files Found" Exit } foreach ($FileInFolder in $FilesInFolder) { #Yes, this could be condensed but I don't like extremely long lines in my ISE. #(or breaking lines if I don't have to) $YearCode = $FileInFolder.Name.Substring(0,4) $MonthCode = $FileInFolder.Name.Substring(4,2) $DayCode = $FileInFolder.Name.Substring(6,2) $HourCode = $FileInFolder.Name.Substring(9,2) $MinuteCode = $FileInFolder.Name.Substring(11,2) $SecondCode = $FileInFolder.Name.Substring(13,2) [datetime]$FileDate = "$YearCode`-$MonthCode`-$DayCode $HourCode`:$MinuteCode`:$SecondCode" write-host "$FileInFolder - $FileDate" $FileInFolder.CreationTime = $FileDate $FileInFolder.LastWriteTime = $FileDate } write-host "" write-host "Done..."

Wednesday, December 2, 2009

State of the Internet

I think the current top 10 downloads from CNET's download.com says it all.


Saturday, November 14, 2009

Hyper-V Server R2

I'm currently attending a conference with a lot of people who own the same kind of companies that I do. It's a fun experience to get to talk to other people who do what I do and face the same things as I do every day.

While the conference is marketing centric, you can't stop IT guys from talking about technology. One conversation that has come up a lot is in regards to virtualization. I'm currently working on two separate virtualization projects for clients. We had to choose a horse, so to speak, between Microsoft and VMWare when it came to the different platforms.

Needless to say, I chose to hitch my cart to the Hyper-V horse in this race. We've seen Microsoft enter markets as the underdog in the past and become the dominant player within a few years. I feel that the virtualization market is going to play out the same way.

You can really tell that they're out to win by the features that they are offering for free. In the past, any kind of clustering required Windows Server Enterprise. If you're using the Hyper-V role on top of Windows Server 2008, you still need Enterprise or better in order to take advantage of the clustering capabilities.

However Microsoft also has a free product called Hyper-V Server 2008 R2. Included for free are some features that are not available with Windows Server Standard running the Hyper-V role, including Cluster Shared Volumes.

Using this free technology, we are able to create highly-available clusters for our clients. With so much running on any one physical machine now, the hardware becomes much more valuable. Using Cluster Shared Volumes (CSV) along with shared storage like iSCSI or Fibre Channel, you can protect your critical systems making sure that even with the total failure of a complete server, you can keep on running.

Our "bread and butter" is small businesses, many of whom are too small to really need this level of virtualization. But I really enjoy working with my larger clients and getting to play with this kind of technology. That's not to say that we don't get to use Hyper-V with our smaller clients. We have many SBS 2008 servers running Hyper-V child machines, and even a few SBS 2008 systems running AS the child machine.

Whether you're using VMWare, Hyper-V or any other technology, virtualization is an amazing technology and I can foresee a day where everything we work on is a virtual machine in some form.

Tuesday, November 10, 2009

Wake on WLAN

We recently deployed 31 brand spakin' new Dell Latitude E5500 laptops to a school here in town. One of the things I noticed in the BIOS settings was the option to Wake on WLAN instead of the usual Wake on LAN. Intel refers to this WoWLAN. But I can't for the life of me get it to work. If anybody searching the web for it and stumbles upon this article (sorry that I'm not offering a solution this time), please come back and post a solution in the comments if you find one.

We would like to be able to do some offline management of these laptops, and wake them up to do so in the cart on the weekend.

We have it set in the BIOS, and under the power management options in Device Manager. What I guess I can't get my head around is how a magic packet reaches a wireless card, especially one with a secured profile, while the system is off. The wireless card is a BCM4310 based Dell Wireless 1395 WLAN Mini-Card.

Any ideas? Is this Intel only?

Friday, April 10, 2009

MoCA Adapters

As a geek, I tend to have a lot of gadgets. This includes a nice cable distribution panel in my basement that makes the cable and satellite guys turn green when they think I need them to do anything on it.

I live in a newer house, but for some reason, Ethernet is not a standard feature of houses like cable outlets and phone jacks.

For the few years I've lived here, I've always wanted to be able to stream HD video to a Windows Media Center Extender up in my bedroom because I record a lot of shows on the Media Center. I use my Media Center to pull ATSC HD off the air. Anything on satellite is recorded on the Dish Network DVR.

A very handy feature of the Dish DVRs is the ability to modulate the second video output to a cable channel for viewing on a separate TV. Basically I can turn the TV in my bedroom to channel 63 (or whatever) and get the full DVR interface. However I was always out of luck when it came to the Media Center.

For a long time, the only extender that could play back HD content was the XBox 360, and I bought a second one just for this purpose. I quickly found out that 802.11g was not fast enough nor reliable enough to do this in my house (AP is in the basement, bedroom is on the second floor). There wasn't any good way to get high speed WIRED network up there.

I have been reading about Ethernet over Coax (aka MoCA) adapters for a few years, and they always seemed like they were about to release. I decided to stop waiting and picked up a couple of Actiontec HME2200 boxes off of Amazon.com.

WHY AREN'T THESE THINGS ON THE SHELF AT EVERY ELECTRONICS STORE?!?!?


I couldn't believe how EASY the install was. It took about a minute per end. Here's a basic layout.



Typical cable uses about the first 1000MHz of the frequencies available on a cable. However most RG6 or Quad Shield is rated to 2350MHz. This leaves quite a bit of bandwidth available for other things. The MoCA adapters put the Ethernet signal onto the unused bandwidth at one end, and pull it off at the other. It's basically a diplexer.

Now if I had an actual satellite tuner in my room (which I don't), I wouldn't be able to use this since it uses the additional bandwidth for that signal.

This has got to be one of the easiest and most useful network devices I have ever used. Powerline is basically worthless, but you can get it at any Best Buy. I'm looking forward to seeing these devices become more available and cheaper in the future.

Monday, April 6, 2009

FixMAPI

Clearly, keeping up on this blog hasn't been at the top of my to-do list. We've made some big changes at Artech, and business is booming at the moment, so I've been busier than ever.

This blog was originally going to be a collection of articles that I could spit out at my own pace, and then use in a newsletter format on a periodic basis to send to our clients. However most of my clients wouldn't really care to read any of this, so it's basically turned into a collection of fixes for which I couldn't find anything on Google when trying to fix an error myself.

A recent example of this came up when I migrated a client from GroupWise 6.5 to Exchange 2007 with Outlook 2007 on the client side. The vast majority of people could no longer use any mailto links or the "Send to" function of Explorer when choosing Mail Recipient. The only solutions people tended to talk about was to verify that you had Outlook selected as the default email program under Internet Explorer.

So if you are being prompted to "Choose Profile", and then nothing happens when trying to use any of these functions, check out the version of your mapi32.dll. There's a program that's been pushed out since IE5 called fixmapi.exe in your system32 directory, which makes a backup of the current MAPI DLL, and restores the correct version. Be careful, because this will break older versions of Outlook.

Hopefully this will help other people when looking for a solution to this issue.

Tuesday, December 16, 2008

Almost Three Months???

I was guessing it was more like two months since my last post. My bad.

I'm working on a few posts that I will hopefully have time to finish in the next few weeks. The biggest one I need to finish (it's been done for months - just need to get a screen shot and make some minor edits) is using AuthAnvil to secure Citrix Web Interface for Presentation Server. We wrote a custom plugin that just adds a passcode field to the login screen. Very handy.

Not really ready to talk about the other ones, but I have experience in a lot of areas. Feel free to shoot me an email or comment if you have anything you'd like to see. Just about anything in the SMB IT market is fair game.