Skip to content

Instantly share code, notes, and snippets.

@0x0dea

0x0dea/skweek.rb Secret

Last active November 3, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 0x0dea/bbc45e4265ff5d6185a7 to your computer and use it in GitHub Desktop.
Save 0x0dea/bbc45e4265ff5d6185a7 to your computer and use it in GitHub Desktop.
foo $ tree
.
├── a
│   ├── 1.m4a
│   ├── 1.mp3
│   └── 2.mp3
├── b
│   ├── 3.m4a
│   ├── 3.mp3
│   ├── 4.mp3
│   ├── 5.m4a
│   └── 5.mp3
├── c
│   ├── 6.mp3
│   ├── 7.m4a
│   ├── 7.mp3
│   ├── 8.m4a
│   └── 8.mp3
└── sad.rb
3 directories, 14 files
foo $
foo $ ruby sad.rb
["a/1.m4a", "b/5.m4a", "b/3.m4a", "c/8.m4a", "c/7.m4a"]
foo $
foo $ cat sad.rb
require 'fileutils'
m4a = Dir['**/*.m4a']
mp3 = Dir['**/*.mp3']
have = m4a & mp3.map { |f| f.sub /mp3$/, 'm4a' }
p have
# FileUtils.rm have
@alact
Copy link

alact commented Nov 3, 2015

m4a = Dir['/*.m4a']
mp3 = Dir['
/*.mp3']

File.dirname(mp3) + '/' + File.basename(mp3).split.('.')[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment